Re: Array Symbol Suggestion
| From: | Donovan Brooke | Date: | Wed, 12 Jan 2011 19:59:39 +0000 |
| Subject: | Re: Array Symbol Suggestion | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310705@lists.php.net to get a copy of this message | ||
sono-io@fannullone.us wrote:
I'd like to make a suggestion for a change, or possibly an addition, to the PHP language. I'm learning PHP and have been very excited with what it can do in relation to HTML. But when I got to the part about arrays, I was disappointed to see that they are designated with a $ the same as other variables. I was learning Perl before I switched, and it uses the @ sign to designate an array. That makes it a lot simpler to see at a glance what is an array and what isn't - at least for beginners like me. Has there been any talk of adopting the @ sign for arrays in PHP? Or is that symbol used for something else that I haven't read about yet? What is the proper channel for making suggestions like this? Thanks, MarcHi Marc, I'm a PHP n00b as well and had similar thoughts regarding this.. just imagine two variables called the same thing.. a string and array.. and accidentally resetting one.. $oops = "something"; however, from my experience, there is often this kind of problem in any language, and that is where naming conventions come in very handy. I don't know if the PHP community has any standard convention.. but I would suggest something like: $a_foo (for arrays) $f_foo (imploding into form variables) $s_foo (string variables) $db_foo (variables coming from databases perhaps) etc.. This way, you'd never be confused of the origin of the variable. Donovan -- D Brooke