Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Robert Peake's Blog:
Typing PHP
Aug 22, 2005 @ 11:01:07

From Robert Peake's weblog today, there's a new post with his look at typing in PHP.

One of the somewhat unique features of PHP is that it is not a strongly typed language. This means that in the event of a type mismatch, variables are automatically cast into whatever variable type (integer, string, etc.) the interpreter deems most appropriate for the operation. Which is typically fine and in fact a boon to most beginning programmers, and fine for experienced programmers that understand the rules of engagement.

He notes that, however, typing in PHP might be confusing to someone either new to the language or more used to a stronger typed language. As a result, he suggests naming varaibles more to do with their contents - such as "user_array" instead of just "users". A sort of knock-off type hinting...

tagged:

Link:


Trending Topics: