#33208 [Opn->Bgs]: define() allows non variable-like strings (spaces, slashes)
| From: | johannes@php.net | Date: | Wed, 01 Jun 2005 13:16:41 +0000 |
| Subject: | #33208 [Opn->Bgs]: define() allows non variable-like strings (spaces, slashes) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79788@lists.php.net to get a copy of this message | ||
ID: 33208
Updated by: johannes@php.net
Reported By: aneroid at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: *Programming Data Structures
Operating System: linux & windows
PHP Version: 5.0.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
see also
http://www.zend.com/zend/week/week218.php#Heading3
Previous Comments:
------------------------------------------------------------------------
[2005-06-01 03:07:13] aneroid at gmail dot com
btw, it may imply corresponding bugs in 'constant()' and 'defined()'.
imho, they would be better left untouched so it's easier to use them as
they currently work. if they are fixed, they should produce
E_WARNING/NOTICEs (worst case) so they can be suppressed with '@' when
checking. this is especially true of constant().
(i'd entered this as a comment but it wasn't displaying)
------------------------------------------------------------------------
[2005-06-01 02:26:17] aneroid at gmail dot com
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 this bug report at http://bugs.php.net/?id=33208&edit=1