Is it best/standard practise to prefix vars with letters indicating datatype?

My supervisors’ code features variable names with letters prefixed to them to indicate the variable type i.e. $iCount (for an integer for use as a counter) or $aDeck (array of results from db query about a deck of cards in a gaming application etc). I was told this is standard universal coding practice. is it?

No. Search “Hungarian Notation” if you want to bore yourself to sleep. :x

I think Hungarian Notation is a stupid practice in a dynamically typed language. A variable can change its type as easily as it can change its value. And adding a bunch of variables can be a lot more confusing then reusing the same variable for the same subject. Thats my opinion anyways.

It’s not a practice I use, though I have seen it used occasionally in VBScript.

IMHO, it’s a poor practice to use in PHP because PHPdoesn’t use strict typing (like logic_earth said), and because mistakes can arise if a variable’s type changes and the name no longer properly represents what it is.

It’s an approach to correct the lack of strict typing in PHP…which doesn’t usually end up working so well.

If you name a variable descriptively enough, you can always tell what kind of data is is supposed to store.

That notation only makes sense in languages that use strict typing and where the programmer is expected to have a bad memory anyd be unable to remember to look back a half dozen lines to where the variable was defined.

$iCount = 0;
if (is_numeric($iCount)) $iCount = ‘nonsense’; // completely valid in PHP