Jump to content

naming vars, functions etc...


poe

Recommended Posts

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..
Link to comment
https://forums.phpfreaks.com/topic/28300-naming-vars-functions-etc/
Share on other sites

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.
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
  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.