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
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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.