ID: 48278 Updated by: [email protected] Reported By: zyss at mail dot zp dot ua Status: Bogus Bug Type: Feature/Change Request Operating System: Irrelevant PHP Version: 5.2.9 New Comment:
There are also edge cases like $a['foo'] = 1; $foo = 2; echo $a[foo]; That would behave differently with optional $'s And I like the obvious separation between constants and variables. It avoids side-effects if someone somewhere suddenly creates a constant that then goes and changes behaviour all over the place because of this constants-over-variables approach. Previous Comments: ------------------------------------------------------------------------ [2009-05-14 19:43:25] zyss at mail dot zp dot ua It will not break stuff if defined constants will have higher priority. In such case developer can just leave $ prefix. It would be really great if PHP developers have an option to choose whether to use the prefix or not. Eventually all new code will be written without $ and there will be no conflicts. ------------------------------------------------------------------------ [2009-05-14 18:24:04] [email protected] And it will most definitely break stuff since removing the $ would clash with any defined constants. ------------------------------------------------------------------------ [2009-05-14 11:07:12] [email protected] Fork away, it is open source after all. ------------------------------------------------------------------------ [2009-05-14 09:04:20] zyss at mail dot zp dot ua Description: ------------ $ character is one of the most widely used in PHP code, in most cases its use is unreasonable. I understand its historical roots, it came from Unix shell scripts (such as bash) where it was required to make interpreters "life" easier. But today's most powerful languages do not require use of variable prefix to distinguish between variable and other identifiers. There are some cases where use of $ if reasonable, for example inside strings and when calling function by name stored in a variable. In all other cases programmers are dazzled by it. I do not propose to remove $ prefix, it would be a major improvement to make it OPTIONAL (this change will not break any existing code but many people will breathe a sigh of relief). P.S. If you will continue to prefer PHP-interpreter developers' convenience over PHP-code developers' we will start our own fork of PHP to be able to add required functionality to it. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48278&edit=1
