|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-09-14 05:44 UTC] 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());
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
Reproducible only with HEAD & 5.0.x. <?php class A { function A($arrayobj) { var_dump($arrayobj); } } class B { } new A( new B() ); ?>