IntroductionPHP supports eight primitive types. Four scalar types:
Two compound types:
And finally two special types:
This manual also introduces some pseudo-types for readability reasons:
And the pseudo-variable Some references to the type "double" may remain in the manual. Consider double the same as float; the two names exist only for historic reasons. The type of a variable is not usually set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used.
To forcibly convert a variable to a certain type, either cast the variable or use the settype function on it. Note that a variable may be evaluated with different values in certain situations, depending on what type it is at the time. For more information, see the section on Type Juggling. The type comparison tables may also be useful, as they show examples of various type-related comparisons. |