ID: 47306 User updated by: michael dot buergi at zhdk dot ch Reported By: michael dot buergi at zhdk dot ch Status: Bogus Bug Type: Feature/Change Request PHP Version: 5.2.8 New Comment:
Dear Johannes Please take the time to read my feature request again and then give some feedback. It has taken me quite some time to post this feature request. So I expect that you take it seriously. You wrote "...this is not a bug.". Of course not, it's a feature request. Since I read the documentation beforehand. So I didn't need the link that you provided me. You wrote "You can atually use any characters as constant name". Besides that sentence not being correct in respect to the documentation, this is simply the point of this feature request, isn't it? It's a bad idea being able to use "any character as constant name" - in particular white space characters like NBSP. Your wrote "if you can\'t trust your developers you have way bigger issues". Ok, let's forget about that comment on sabotage. It's important to note that most NBSPs in PHP programs are there by mistake - p.e. by copy/pasting from a website or pressing alt-space (instead of just space) on a mac which can happen even to the most trusted developers. regards Michael Previous Comments: ------------------------------------------------------------------------ [2009-02-06 22:40:30] [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 You can atually use any characters as constant name and if you can\'t trust your developers you have way bigger issues ... ------------------------------------------------------------------------ [2009-02-04 16:18:10] michael dot buergi at zhdk dot ch Description: ------------ current situation: Since PHP allows the characters 0x7f through 0xff in constant names, you can create constant names that contain non-printable characters - like the non-breaking space (NBSP) chr(160)! Sadly, any PHP-IDE (p.e. the Zend Studio for Eclipse) or editor that I have checked with recognises NBSP as whitespace. So this seems to be a perfect way to sabotage someones code. Just replace an ordinary space with NBSP and you are screwed. I pasted a small php script into "reproduce code" that defines a constant and echoes it two times, as it seems. But since there is a NBSP in front of the constant's name, PHP just echoes " SOME_CONST". the second echo is completely ignored since it searches for the constant "echo SOME_CONST". Motivation: Look at the sample script in a PHP editor and you won't find any error. Only in case you have E_NOTICE reporting turned on (which I don't) you would eventually find the mistake. change request: Having non-printable characters in constant names seems to be a bad idea for me. therefore I request that not the whole 0x7f-0xff character range could be used in constant names, but just the sane ones. And since I'm already here, why not raise the error-level from "notice" to "warning" if a constant's name is not found? You could introduce a php.ini flag that controls this behaviour. Thank you very much and kind regards Michael Reproduce code: --------------- <?php error_reporting(E_ALL); define('SOME_CONST', 'foobar'); echo SOME_CONST; echo SOME_CONST; ?> Expected result: ---------------- foobarfoobar Actual result: -------------- SOME_CONST ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47306&edit=1
