[PHP]Comparison

개발관련/PHP 2012. 4. 20. 15:18 |
name = "changed box";

$another_box = new Box();

// == is casual and just checks to see if the attributes are the same
echo $box == $box_reference ? 'true' : 'false'; // true
echo "
"; echo $box == $box_clone ? 'true' : 'false'; // true echo "
"; echo $box == $box_changed ? 'true' : 'false'; // false echo "
"; echo $box == $another_box ? 'true' : 'false'; // true echo "

"; // === is strict and checks to see if they reference the same object echo $box === $box_reference ? 'true' : 'false'; // true echo "
"; echo $box === $box_clone ? 'true' : 'false'; // false echo "
"; echo $box === $box_changed ? 'true' : 'false'; // false echo "
"; echo $box === $another_box ? 'true' : 'false'; // false echo "
"; ?>

true
true
false
true

true
false
false
false

'개발관련 > PHP' 카테고리의 다른 글

[PHP]Date & Time Format  (0) 2012.04.20
[PHP]Constructors  (0) 2012.04.20
[PHP]Cloning  (0) 2012.04.20
[PHP]Class Example 5  (0) 2012.04.20
[PHP]Class Example 4  (0) 2012.04.20
Posted by 파노카페
: