Paul Peelen
Paul Peelen

Reputation: 10329

Name of code style

When I develop my PHP code I always write it a certain way, I use the following to define my variables:

$sString
$aArray
$bBoolean
$oObject
$mMixed
$iInteger
$a_sString/aArray/bBoolean ect (for function argument)

Hence s, a, b, o, m, i ect. I know there is a name to call this type of writing, but I have totally forgotten it.

My question: What is this called?

Upvotes: 4

Views: 116

Answers (4)

oezi
oezi

Reputation: 51797

this is some kind of hungarian notation, but some kind (seems to be very close to pahn) of the missunderstood and useless one*. take a look at joels great article about hungarian notation and how to use it the correct way.

*just using a prefix to see what type a variable should be isn't very useful - it you be way better to prefix them with something that defines what kind of variable this is. an example:

lets assume you have some variables containing different currencys (euros and dollars, in cents for your case as you havnt given a prefix fpr floats, so i'll use integers) and a function to ververt one to another. in your case:

$iPriceAmerica = 500;

// would be the right way
$iPriceEurope = iEuroFromDollar($iPriceAmerica);

// looks right and is possible as both are integers
// but is wrong (correct executable code, but doesn't give the expected result)
$iPriceEurope = $iPriceAmerica;

with correct hungarian notation, using dol_ for dollars and eur_ for euros:

$dol_PriceAmerica = 500;

// would be the right way
$eur_PriceEurope = eur_from_dol($dol_PriceAmerica);

// looks wrong - eur isn't dol, there muste be some kind of conversion
$eur_PriceEurope = $dol_PriceAmerica;

Upvotes: 0

Jon
Jon

Reputation: 437366

It's called hungarian notation.

Note: There are many different "flavors" of Hungarian. "Hungarian" by itself describes the practice of prefixing variable names with a few characters that provide additional information about the contents of the variable. What kind of information is what defines the actual flavor in use.

Upvotes: 3

Metaller
Metaller

Reputation: 514

Hungarian notation is an identifier naming convention in computer programming, in which the name of a variable or function indicates its type or intended use.

Upvotes: 0

paulsm4
paulsm4

Reputation: 121649

It's similar to "Hungarian", but it's actually PAHN.

Upvotes: 4

Related Questions