[PHP] Broken compatibility with escaping { in php 5.2
Hi all, Try this: $a = ''; echo \{$a}; from php 4, it outputs {}, from php 5.2 (one that comes with Zend 5.5) it outputs \{}, thus breaking existing scripts. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken compatibility with escaping { in php 5.2
Bogdan Ribic wrote: Hi all, Try this: $a = ''; echo \{$a}; from php 4, it outputs {}, from php 5.2 (one that comes with Zend 5.5) no-one here supports Zend. it outputs \{}, thus breaking existing scripts. AFAICT the escaping in that string is wrong - the fact that it did work the way you want it to is probably sheer luck. lastly I ran your tests and determined at the least that the 'break' occur *prior* to 5.2. at a guess it probably changed in 5.0, here are my results: # php -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' ; php5 -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' OUTPUT: php4.3.10-18: string(2) {} php5.1.2: string(3) \{} be pragmatic - fix your script :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken compatibility with escaping { in php 5.2
On cs, 2007-01-18 at 14:19 +0100, Jochem Maas wrote: Bogdan Ribic wrote: Hi all, Try this: $a = ''; echo \{$a}; from php 4, it outputs {}, from php 5.2 (one that comes with Zend 5.5) no-one here supports Zend. it outputs \{}, thus breaking existing scripts. AFAICT the escaping in that string is wrong - the fact that it did work the way you want it to is probably sheer luck. lastly I ran your tests and determined at the least that the 'break' occur *prior* to 5.2. at a guess it probably changed in 5.0, here are my results: # php -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' ; php5 -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' OUTPUT: php4.3.10-18: string(2) {} php5.1.2: string(3) \{} be pragmatic - fix your script :-) is this the correct form: $a = ''; echo \{$a\}; if I want to get {} a result? (I think it is) greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken compatibility with escaping { in php 5.2
Németh Zoltán wrote: On cs, 2007-01-18 at 14:19 +0100, Jochem Maas wrote: Bogdan Ribic wrote: Hi all, Try this: $a = ''; echo \{$a}; from php 4, it outputs {}, from php 5.2 (one that comes with Zend 5.5) no-one here supports Zend. it outputs \{}, thus breaking existing scripts. AFAICT the escaping in that string is wrong - the fact that it did work the way you want it to is probably sheer luck. lastly I ran your tests and determined at the least that the 'break' occur *prior* to 5.2. at a guess it probably changed in 5.0, here are my results: # php -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' ; php5 -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});' OUTPUT: php4.3.10-18: string(2) {} php5.1.2: string(3) \{} be pragmatic - fix your script :-) is this the correct form: $a = ''; echo \{$a\}; if I want to get {} a result? (I think it is) testing would given you certainty. I tested it and, although I would have thought it was correct, it did not given the desired result, the following 2 do give what your looking for: echo {{$s}}, , '{'.$s.')'; greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken compatibility with escaping { in php 5.2
be pragmatic - fix your script :-) I did :) It was a part of code generator, and I had something like : $res .= function $this-insert_prefix() \{$this-_global_db\n; and replaced it with $res .= function $this-insert_prefix() {{$this-_global_db}\n; ... in about 20 locations. But the complaint is that whichever is correct version, it cannot be much more correct than the other, and certainly not worth breaking existing functionality. Mine was easy to fix, but this might introduce weird bugs somewhere else. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken compatibility with escaping { in php 5.2
Bogdan Ribic wrote: be pragmatic - fix your script :-) I did :) It was a part of code generator, and I had something like : $res .= function $this-insert_prefix() \{$this-_global_db\n; and replaced it with $res .= function $this-insert_prefix() {{$this-_global_db}\n; ... in about 20 locations. But the complaint is that whichever is correct version, it cannot be much more correct than the other, and certainly not worth breaking existing functionality. Mine was easy to fix, but this might introduce weird bugs somewhere else. I'm not the authority that could comment on that one way or the other, no doubt there is a good complicated explanation as to why this changed - you might try asking the internals list (don't tell them I sent you :-). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php