PHP基础-变量类型转换

'one','b'=>'two'); //数组
$var_arrays = array("cn"=>array('a'=>'one','b'=>'two'),
    "en"=>array('a'=>'one','b'=>'two'));   //多维数组

echo "使用gettype()函数,查看变量转换前的类型:
"; echo "var_int =".gettype($var_int)."
"; echo "var_integer = ".gettype($var_integer)."
"; echo "var_string = ".gettype($var_string)."
"; echo "var_bool = ".gettype($var_bool)."
"; echo "var_float = ".gettype($var_float)."
"; echo "var_object = ".gettype($var_object)."
"; echo "show_1 = ".gettype($show_1)."
"; echo "\$\$show_1 = ".gettype($$show_1)."
"; echo "show_3 = ".gettype($show_3)."
"; echo "var_array = ".gettype($var_array)."
"; echo "var_arrays = ".gettype($var_arrays)."
"; echo "
"; $var_int = "$var_int"; //转换为字符串 $var_integer = (int)$var_integer; //强制转换为int settype($var_object,"object"); //设置为对象 $var_array = (int)$var_array; //强制转换为整形 $var_arrays = (object)$var_arrays; //数组强制转换为对象 $show_3 = $$show_1; //转换为布尔型 echo "使用gettype()函数,查看变量转换后的类型:
"; echo "var_int = ".gettype($var_int)."
"; echo "var_integer = ".gettype($var_integer)."
"; echo "var_object = ".gettype($var_object)."
"; echo "var_array = ".gettype($var_array)."
"; echo "var_arrays =".gettype($var_arrays)."
"; echo "\$show_3 = ".gettype($show_3)."
";

 

你可能感兴趣的:(php)