public function loadModel()
{
if($this->_model===null)
{
if(isset($_GET['id']))
{
if(Yii::app()->user->isGuest)
Somebody told me before "===" not only compare the value is equal, but also compare if the data type is the same. Is this claim true? Can you tell me where to find reference of the === operator?
If it’s true, then what the difference does it make in using == or === in the following code?
=== is faster than == since there is no type-conversion. The speed difference is most likely negligible, though we use it everywhere in the core.
Personally I think it should be common practice to always use === if it fits. I like strictness and I see no reason to spend additonal CPU time for nothing.
if($level==0)
{
// if $level IS zero... do some very critical operation
echo "IS zero";
}
else
{
// if $level is not zero just output an error
echo "NOT zero";
}
Now… the code is very simple and there is nothing wrong with it… right… or is there?
Try to assign the variable $level any text like $level="anytextyoulike" and check the result…
I leave to you to find the reason why this is happening…
by doing this you will understand best the difference between == and ===