Changes

An Introduction to PHP Variables

No change in size, 17:19, 25 May 2007
Changing the Type of a PHP Variable
== Changing the Type of a PHP Variable ==
As we mentioned at the beginning of this chapter, PHP supports a number of different variable types (specifically integer, float, boolean, array, object, resource and string). We will look at these types in detail in the nect next chapter ([[Understanding PHP Variable Types]]). First we are going to look at changing the type of a variable after it has been created.
PHP is what is termed a ''loosely typed'' language. This contrasts with programming languages such as Java which are ''strongly typed'' languages. The rules of a strongly typed language dictate that once a variable has been declared as a particular type, its type cannot later be changed. In Java, for example, you cannot assign a floating point number to a variable that was initially declared as being a string.