|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2005-06-01 03:07 UTC] aneroid at gmail dot com
  [2005-06-01 15:16 UTC] johannes@php.net
  [2005-06-01 16:05 UTC] aneroid at gmail dot com
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
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)