PHP ʖ²ἯTH
º/A
Ղ 7. Ѝ
ЍϷ·¨
$foo = "0"; // $foo is string (ASCII 48) $foo += 2; // $foo is now an integer (2) $foo = $foo + 1.3; // $foo is now a float (3.3) $foo = 5 + "10 Little Piggies"; // $foo is integer (15) $foo = 5 + "10 Small Pigs"; // $foo is integer (15)
ע: ʽשµėԶ¯ת»»АΪĿǰûӐ¶¨ҥ¡£
Ѝǿֆת»»
PHP µĀЍǿֆת»»º͠C µķdz£ϱ£ºԚҪת»»µı䁿֮ǰ¼ӉϓÀ¨ºŀ¨ư4µĄ¿±ꀠЍ¡£
$foo = 10; // $foo is an integer $bar = (boolean) $foo; // $bar is a boolean
ԊЭµć¿ֆת»»Ӑ£º
(float), (double), (real) - ת»»³ɸ¡µ㐍
(array) - ת»»³Ɋÿ©¼¯
(object) - ת»»³ɶԏ
$foo = (int) $bar; $foo = (int) $bar;
$foo = 10; // $foo is an integer $str = "$foo"; // $str is a string $fst = (string) $foo; // $fst is also a string // This prints out that "they are the same" if ($fst === $str) {echo "they are the same";}
ת»»ΪջЍ
ת»»Ϊ¸¡µ㐍
ת»»Ϊʽש
ת»»Ϊ¶ԏ
ת»»ΪԴ
º/A
ưµ㼯A
±¾΄µµʹӃµĎ± Ѝ
ɏһ¼¶
±䁿