3pod PHP Learning |
"color" => "yellow", "taste" => "paste-y", "shape" => "banana-shaped" ) ); echo $a["apple"]["taste"]; # will output "sweet" ?> Objects Object Initialization To initialize an object, you use the new statement to instantiate the object to a variable. class foo { function do_foo () { echo "Doing foo."; } } $bar = new foo; $bar -> do_foo (); Type juggling PHP does not require (or support) explicit type definition in variable declaration; a variable’s type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable var, varbecomes a string. If you then assign an integer value to var, it becomes an integer. An example of PHP’s automatic type conversion is the addition operator ’+’. If any of the operands is a double, then all operands are evaluated as doubles, and the result will be a double. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated. $foo = "0"; // $foo is string (ASCII 48) $foo++; // $foo is the string "1" (ASCII 49) $foo += 1; // $foo is now an integer (2) 84 |
Next >> |
Tripod >> 3pod Tips & Learning and manuals for educations