ID: 30080 Comment by: php30080 at pointbeing dot net Reported By: portfolio at gmx dot co dot uk Status: Open Bug Type: Reproducible crash Operating System: XP PHP Version: 5.0.1 New Comment:
Behaviour is reproducible using 5.00 on Fedora Linux (core 2). There's an ongoing discussion of the behaviour on the Sitepoint forums here: http://www.sitepoint.com/forums/showthread.php?t=195284 By way of a summary, it appears that the problems occur when constructing a number of new objects without assigning them anywhere, so: new A( array( new B(), new C())); // fails $a = new A( array( new B(), new C())); // fine some_function( array( new B(), new C())); //fine Previous Comments: ------------------------------------------------------------------------ [2004-09-14 05:44:10] portfolio at gmx dot co dot uk Description: ------------ When I pass an array of objects without first initializing them with a variable, I get either a crash or error (Depends on whether if its array). Reproduce code: --------------- class A { function A($arrayobj) { while(list($key, $value) = each($arrayobj)) { echo $value->spit(); } } } class B { function spit() { return 'This is class B' . "\n"; } } class C { function spit() { return 'This is class C' . "\n"; } } new A( array( new B(), new C())); Expected result: ---------------- I got this error: This is class B Fatal error: Call to a member function spit() on a non-object in If I do: $b = new B; $c = new C; new A( array($b, $c)); It works but very long winded. Another bug here causes Apache to crash: class A { function A($value) { echo $value->spit(); } } class B { function spit() { return 'This is class B' . "\n"; } } new A( new B()); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30080&edit=1