[prev] [index] [next]

Variables (cont)

Examples:

$foo = 3;          # $foo is an int, value 3

$foo = "8";        # $foo is now a string, value "8"

$foo = $foo + 2;   # $foo is now an int, value 10

$foo = "$foo green bottles";
                   # $foo is now "10 green bottles"

$foo = 3.0 * $foo; # $foo is now double, value 30.0

$foo = (int)$foo;  # $foo is now an int, value 30