2011-11-16

[PHP] Equal vs. Identical

Equal: ==
Identical: ===
兩個都是用來進行比較運算的 "Comparison Operators"
有什麼不一樣呢?

如果是要比較不同的資料型態時,
使用 "Equal" 時,會先轉換成相同的資料型態,再進行比較
使用 "Identical" 時,不會轉換資料型態


Reference:
http://blog.roodo.com/rocksaying/archives/2565180.html
http://www.php.net/manual/en/language.operators.comparison.php
http://www.php.net/manual/en/types.comparisons.php

沒有留言 :

張貼留言