#18872 [NEW]: Improper handling of class constants used as default function argument values

From: Date: Tue, 13 Aug 2002 03:27:04 +0000
Subject: #18872 [NEW]: Improper handling of class constants used as default function argument values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16563@lists.php.net to get a copy of this message
From: optikSmoke@subdimension.com Operating system: Mandrake 8.2 (linux 2.4.18) PHP version: 4CVS-2002-08-12 PHP Bug Type: Zend Engine 2 problem Bug description: Improper handling of class constants used as default function argument values I am using CVS from August 12, compiled with Zend2, as a module in Apache 1.3.23. My problem is this: When I use a class constant as the default value to an argument in a function, the first time I call the function (omitting the argument), PHP correctly uses the value of the constant for the value of the omitted argument. The second time I call the same function (again omitting the argument), PHP uses a slightly-garbled form of the name of the class constant, instead of the value of the constant. For example: <? class FooBar { const BIFF = 3; } function foo($biff = FooBar::BIFF) { echo $biff . "\n"; } foo(); foo(); ?> The expected output of this is (obviously): 3 3 The output I get is: 3 foobar :BIFF (The space before ":BIFF" should be a non-printing character, rendered as a box on my system, but I'm not sure if it will come through properly :) This error does not occur when using regular "define()'d" constants. For example, if I replaced FooBar::BIFF with a constant BIFF, I get the expected output (no garbled constant names, "3" is displayed by each call to foo()). -- Edit bug report at http://bugs.php.net/?id=18872&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18872&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18872&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18872&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18872&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18872&r=support Expected behavior: http://bugs.php.net/fix.php?id=18872&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18872&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18872&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18872&r=globals

« previous php.bugs (#16563) next »