can any one please let me know the global declaration of php variables..i have seen one among the site like..
for integer start with i, eg: $iItemId for array start with a, eg: $aItemIds for string start with s, eg: $sItemName
can any one please let me know the global declaration of php variables..i have seen one among the site like..
for integer start with i, eg: $iItemId for array start with a, eg: $aItemIds for string start with s, eg: $sItemName
I do not use such conventions, and it is rare to see this in php, it's more a VB thing I guess...
If you give good names to variable, their types will appear. For instance, the not so strict conventions I use vor variable naming :
$i
, $j
, $k
, $l
, etc. and all single letters variables are integers used as counters$messageRow
=> it's a DB result instance$messageCollection
=> it's results collection$messageRows
=> array , Using plural denotes multiple items$messageTitle
=> it's a string$messageVisible
or $isMessageVisible
=> it's a booleanIn fact everithing now tends to be object, except array and strings, and good naming with good comment and/or visible typecast (mainly on methods arguments, or specific use) makes variables more readable code and guessing types is easier than having a whole bunch of $oThis
and $oThat
God, no!
Avoid like hell idiotic names LikeThisOne.
Never ever use caps in a variable name, unless it's ALLCAPS.
Use underscore to separate words if you need to.
What you're describing is called Hungarian Notation, nobody seems to have mentioned that yet.
In answer to your question, I would suggest using whatever style you're most comfortable with. As long as it's consistent and readable it doesn't really matter. That said, hungarian notation isn't the most readable style...
Use the style you are comfortable with.
But also take into account the frameworks you are using. If you use mostly the Zend Framework choosing a style different to their style may lead to "visually confusing" code, since the style switches.