Jump to content

Archived

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

nyi8083

Variable Names

Recommended Posts

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?

Share this post


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

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=102653.msg407725#msg407725 date=1154481041]
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.
[/quote]

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

Share this post


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

[b]Invalid vars:[/b]
$ name
$1234
$-somename

[b]Valid vars:[/b]
$__1name2__
$_name1
$name1234
$name

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

Share this post


Link to post
Share on other sites

×

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.