NULL
$null_val = NULL;
var_dump(is_null($null_val));
BOOLEAN
$bool_val = TRUE;
echo get_debug_type($bool_val). PHP_EOL;
var_dump($bool_val);
INTEGER
$int_val = 1234;
echo get_debug_type($int_val). PHP_EOL;
var_dump($int_val);
FLOAT
$float_val = 1.234;
echo get_debug_type($float_val). PHP_EOL;
var_dump($float_val);
STRING
$str_val = "apple";
echo get_debug_type($str_val). PHP_EOL;
var_dump($str_val);
echo 'He drank some $str_val juice. \n apple' . PHP_EOL;
echo "He drank some $str_val juice. \n apple" . PHP_EOL;
var_dump("0" == 0); //ok
var_dump("001" == 1); //ok
위와같은 특수한 경우 문자열은 숫자와 비교가능하다
ARRAY
$array_val1 = array(1,2,3);
var_dump($array_val1);
$array_val2 = array(
"foo" => "bar",
1 => "foo",
"multi" => array(
"dimensional" => array(
"array" => "foo"
)
)
);
var_dump($array_val2);
foreach ($array_val1 as $array_val1_item) {
echo "Do you like $array_val1_item?\n";
}
$array_val3 = serialize($array_val1);
var_dump($array_val3);
$array_val4 = unserialize("a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}");
var_dump($array_val4);
PHP의 배열은 MAP의 성격을 같이 띈다
형변환
<?php
$foo = 10; // $foo is an integer
$bar = (bool) $foo; // $bar is a boolean
?>