On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:
> Hello Everybody
> I start to write PHP script and all veritable a defined without some
> rules. I want to ask to you somebody know how is correct do different
> some variable.
> Like from next three variable who is correct:
> $firstname $FirstName $firstName $first_name etc.
> I know that from this variable can work all, but i want to know how is
> use in company.
> Do you have some standard for defined the variable in program language?
> (like ISO9001, ISO14001)
> Best Regard,
> Jordan Jovanov
There is no enforced standard on how you define your variable names in
PHP. However, you should try and remain consistent with whichever way
you decide to use. Personally, I find the $firstName style the best of
the four examples you gave. It's easily readable when I look over code
at a later date, and slightly faster to type than $first_name (although
even if only by a mere fraction of a second!)
Some existing codebases might use a particular method though, and if
you're working on a project with a team, then it really helps to all be
using the same convention of naming variables.
At the end of the day, this is all down to preference, along with code
indentation and layout.