Jump to content


Photo

Variable Names


  • Please log in to reply
4 replies to this topic

#1 nyi8083

nyi8083
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 August 2006 - 01:07 AM

Does it matter if I use the same variable names in different php files? Is this a bad practice or does this really not matter at all?


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 August 2006 - 01:10 AM

the ansaw is no.

but the varable names should reflect what your creating.

example varables with meanfull meaning.

$name is varable for name.
$fname is varable for first name.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Colleen78

Colleen78
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationCanada

Posted 02 August 2006 - 01:29 AM

the ansaw is no.

but the varable names should reflect what your creating.

example varables with meanfull meaning.

$name is varable for name.
$fname is varable for first name.


That's handy good advice, thanks redarrow, I am learning so I find these tips very handy. :)

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 August 2006 - 01:31 AM

aytime good looking.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 August 2006 - 10:26 AM

Keep in mind variables should either start of with an underscore (_) or a letter, after that they can contain any number of underscores/letters/numbers etc.

Invalid vars:
$ name
$1234
$-somename

Valid vars:
$__1name2__
$_name1
$name1234
$name

Redarrows advice is very good, you should name your variables accordingly.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users