#35052 [NEW]: $var-$arrayname['item'] fails
From: sam at liddicott dot com Operating system: Linux PHP version: 4.4.0 PHP Bug Type: Scripting Engine problem Bug description: $var-$arrayname['item'] fails Description: Indirect object array access $var-$arrayname['item'] only takes the first letter of the array name Reproduce code: --- ?php # THIS FAILS $name=list; $obj-$name['item']='test'; var_dump($obj); ? ?php # THIS WORKS FINE $name=list; $array=$obj-$name; $array['item']='test'; var_dump($obj); ? Expected result: object(stdClass)(1) { [list]= string(4) test } Actual result: -- object(stdClass)(1) { [l]= string(4) test } -- Edit bug report at http://bugs.php.net/?id=35052edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35052r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35052r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35052r=trysnapshot51 Fixed in CVS:http://bugs.php.net/fix.php?id=35052r=fixedcvs Fixed in release:http://bugs.php.net/fix.php?id=35052r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35052r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35052r=needscript Try newer version: http://bugs.php.net/fix.php?id=35052r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35052r=support Expected behavior: http://bugs.php.net/fix.php?id=35052r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35052r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35052r=submittedtwice register_globals:http://bugs.php.net/fix.php?id=35052r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35052r=php3 Daylight Savings:http://bugs.php.net/fix.php?id=35052r=dst IIS Stability: http://bugs.php.net/fix.php?id=35052r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35052r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35052r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35052r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35052r=mysqlcfg
#35053 [NEW]: === is wrong for objects and also stupid
From: sam at liddicott dot com Operating system: Linux PHP version: 4.4.0 PHP Bug Type: Scripting Engine problem Bug description: === is wrong for objects and also stupid Description: === does not compare two objects for identity, it compares the values of their fields, and recursively at that! It gives wrong answers and in some cases fails altogether! Would you believe that === reports two different objects as being the same object, when they are not references? Why can't it just check if they have the same storage address, that should be quick, painless and accurate! There should be some way to tell when two object references refer to the same object (apart hack in an extra field and see if it appears in the other) Reproduce code: --- ?php $t-name='t'; $e-name='e'; $t-e=$e; $e-t=$t; $tt=$t; $a-n='n'; $b-n='n'; if ($a===$b) print Dear me A and B are the same\n; else print Of course A and B are different\n; if ($tt===$t) print Yes, of course TT and T are the same\n; else print No they are not\n; ? Expected result: Of course A and B are different Yes, of course TT and T are the same Actual result: -- Dear me A and B are the same Fatal error: Nesting level too deep - recursive dependency? in /home/sam/projects/reporter/t.php on line 17 -- Edit bug report at http://bugs.php.net/?id=35053edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35053r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35053r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35053r=trysnapshot51 Fixed in CVS:http://bugs.php.net/fix.php?id=35053r=fixedcvs Fixed in release:http://bugs.php.net/fix.php?id=35053r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35053r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35053r=needscript Try newer version: http://bugs.php.net/fix.php?id=35053r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35053r=support Expected behavior: http://bugs.php.net/fix.php?id=35053r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35053r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35053r=submittedtwice register_globals:http://bugs.php.net/fix.php?id=35053r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35053r=php3 Daylight Savings:http://bugs.php.net/fix.php?id=35053r=dst IIS Stability: http://bugs.php.net/fix.php?id=35053r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35053r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35053r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35053r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35053r=mysqlcfg
#35053 [WFx]: === is wrong for objects and also stupid
ID: 35053 User updated by: sam at liddicott dot com Reported By: sam at liddicott dot com Status: Wont fix Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 4.4.0 New Comment: Well why not add a new operator that does the job properly? Or a function getAddressOfObject (a 5 liner, surely) that returns the address of the object so a numeric compare can be done, or something that does the job that needs doing? Sam Previous Comments: [2005-11-01 17:06:31] [EMAIL PROTECTED] We can not change this behavior, as this might break existing scripts. [2005-11-01 17:02:32] sam at liddicott dot com Description: === does not compare two objects for identity, it compares the values of their fields, and recursively at that! It gives wrong answers and in some cases fails altogether! Would you believe that === reports two different objects as being the same object, when they are not references? Why can't it just check if they have the same storage address, that should be quick, painless and accurate! There should be some way to tell when two object references refer to the same object (apart hack in an extra field and see if it appears in the other) Reproduce code: --- ?php $t-name='t'; $e-name='e'; $t-e=$e; $e-t=$t; $tt=$t; $a-n='n'; $b-n='n'; if ($a===$b) print Dear me A and B are the same\n; else print Of course A and B are different\n; if ($tt===$t) print Yes, of course TT and T are the same\n; else print No they are not\n; ? Expected result: Of course A and B are different Yes, of course TT and T are the same Actual result: -- Dear me A and B are the same Fatal error: Nesting level too deep - recursive dependency? in /home/sam/projects/reporter/t.php on line 17 -- Edit this bug report at http://bugs.php.net/?id=35053edit=1