ID:               33208
 User updated by:  aneroid at gmail dot com
 Reported By:      aneroid at gmail dot com
 Status:           Bogus
 Bug Type:         *Programming Data Structures
 Operating System: linux & windows
 PHP Version:      5.0.3
 New Comment:

i hardly think it's "not a bug". but i DO agree with the reasons for
leaving the behaviour as is, particularly: to not break existing code
and speed (as mentioned in
http://www.zend.com/zend/week/week218.php#Heading3).

nothing in the manual about constants
(http://www.php.net/manual/en/language.constants.php) or define()
(http://www.php.net/manual/en/function.define.php) documents this
behaviour.

anyways. thanks for clarifying things.


Previous Comments:
------------------------------------------------------------------------

[2005-06-01 15:16:40] [EMAIL PROTECTED]

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 

------------------------------------------------------------------------

[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

Reply via email to