wierd function behavior within classes.. Bug?

From: Date: Thu, 24 Jan 2002 23:52:19 +0000
Subject: wierd function behavior within classes.. Bug?
Groups: php.general 
Request: Send a blank email to php-general+get-82009@lists.php.net to get a copy of this message
I'm not sure if this is a known feature in php.. but the following code will generate this warning: Warning: Missing argument 2 for foo() in /raid/htdocs/test.php on line 7 ----------------- <? class Foo { function Foo($bar) { // no argument constructor echo "One argument Constructor.\n<br>\n"; } function Foo($bar,$baz) { // one argument constructor echo "Two argument constructor.\n<br>\n"; } } $foo = new Foo("foobared constructor"); ?> --------------------- while simply swapping the functions around removes the warning --------------------- <? class Foo { function Foo($bar,$baz) { // one argument constructor echo "Two argument constructor.\n<br>\n"; } function Foo($bar) { // no argument constructor echo "One argument Constructor.\n<br>\n"; } } $foo = new Foo("foobared constructor"); ?> ---------------------- This is running on php version 4.0.3pl1 Is it supposed to be this way for some reason or is this a bug? I believe I found that it happens with all functions within a class (not just constructors). Thanks -- ------------------------- Marc Swanson MSwanson Consulting Phone: (603)868-1721 Fax: (603)868-1730 Mobile: (603)512-1267 mswanson@mswanson.com http://www.mswanson.com -------------------------

« previous php.general (#82009) next »