#33208 [NEW]: define() allows non variable-like strings (spaces, slashes)

From: Date: Wed, 01 Jun 2005 00:26:36 +0000
Subject: #33208 [NEW]: define() allows non variable-like strings (spaces, slashes)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79778@lists.php.net to get a copy of this message
From: aneroid at gmail dot com Operating system: linux & windows PHP version: 5.0.3 PHP Bug Type: *Programming Data Structures Bug description: define() allows non variable-like strings (spaces, slashes) Description: ------------ define()ing a constant with spaces, / signs, etc. doesn't throw an error (or warning). i happened to try to create a constant with the name 'U/L DIR' and it worked. that's two illegal chars. since constant names like "2FOO" are checked and not allowed, shouldn't these also not be allowed? sure doesn't satisfy "The name of a constant follows the same rules as any label in PHP." or the regexp [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* a name like that obviously can't be used (tried quotes and braces) but it works just fine with 'defined()', 'constant()' and shows up in get_defined_constants(). Reproduce code: --------------- define('U/L DIR', 'myuploaddir'); if (defined('U/L DIR')) { //true echo 'yup'; echo constant('U/L DIR'); print_r(get_defined_constants()); } // all the lines above print 'myuploaddir' for 'U/L DIR' Expected result: ---------------- E_ERROR since it's violates label rules (an E_WARNING at the least?) Actual result: -------------- spaces, etc. work just fine. (it shouldn't) -- Edit bug report at http://bugs.php.net/?id=33208&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33208&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33208&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33208&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33208&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33208&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33208&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33208&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33208&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33208&r=support Expected behavior: http://bugs.php.net/fix.php?id=33208&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33208&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33208&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33208&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33208&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33208&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33208&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33208&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33208&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33208&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33208&r=mysqlcfg

« previous php.bugs (#79778) next »