poe Posted November 24, 2006 Share Posted November 24, 2006 is there a 'standard' as to naming variables, arrays, functions etc...i guess you could give them any name you want, but as i go along i seem to create more and more and i get more and more confussed as to what is what.i may have a var:$petName = 'fido';i may have an array:$petNameArray = ('fido', 'max', 'rover');i may also have a function that gets the pet names from a database:function getPetNames();i guess i am looking for a better way to track all my arrays / functions / vars.. Quote Link to comment Share on other sites More sharing options...
btherl Posted November 24, 2006 Share Posted November 24, 2006 Your variable naming looks pretty good to me :)Variable naming is an art rather than a science.. there's no correct way or wrong way. There are certainly bad ways, like naming all your variables $foo1, $foo2, $foo3 :) The real test is when you forget what your code does and try to reverse-engineer it.. then you see how good your naming was. And good variable naming will reduce debugging time considerably, since you won't have mistakes due to forgetting what variables really are. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 24, 2006 Share Posted November 24, 2006 I do not like camelCase names. I use an underscore to separate pieces of names to make them more readable. I'd much rather have all my variable names in lowercase, so I am not burnt by using the wrong case. Also, I use short variable names when dealing with temporary variables.Ken Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted November 24, 2006 Share Posted November 24, 2006 i agree with kenrbnsn about the capitals in the variable. although i must admit i do have capitals in some function names. depends really. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 I prefer camelCase. The only naming I hate is Hungarian Notation. As long as you do it the same way all the time, you won't get too confused. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.