Weird behavior using IF statement in PHP
<p>I am noticing some weird behavior in my script, not sure why its occurring though.</p>

<pre><code>if ($date != 'NOW()' ||  $date != 'NULL')
{
   // throw error      
} else {
   // run functions
}
</code></pre>

<p>I have a IF statement similar to the above in one of my functions, i pass the value <code>'NULL'</code> from my function which it is receiving fine. But when doing the comparison with the IF statement, it doesn't work. Its always skipping to else statement.</p>

<p><strong>UPDATE:</strong><br>
Below is the complete code for my function, i hope it helps.</p>

<pre><code>public function setLastLoginDate( $date )
{
    if (isset($date) &amp;&amp; !empty($date))
    {
        if ($date != 'NOW()' ||  $date != 'NULL' || is_datetime(convertDateTimeToSql($date)) == false)
        {
            $this-&gt;errors['user_last_login'] = 'invalid date specified.';
        } else {
            this-&gt;properties['user_last_login'] = $date;
        }
    }
}
</code></pre>

<p><strong>LAST UPDATE</strong><br>
Using &amp;&amp; does work instead of ||, but i never intended to use &amp;&amp;.
if thats the way it is suppose to be then i guess i have to reRead about that.</p>

<p>Isn't &amp;&amp; to check if two variables return true?
like <code>if (is_string($foo) &amp;&amp; strlen($foo) &gt; 1)</code> ?
but i want to check if the variable contains either of the values</p>

<p>But this also does the trick for me:</p>

<pre><code>if ( $date == 'NOW()' ||  $date == 'NULL' || is_datetime(convertDateTimeToSql($date)) == true )
{
    $this-&gt;properties['user_last_login'] = $date;
} else {
    $this-&gt;errors['user_last_login'] = 'invalid date specified.';
}
</code></pre>

<p>Did some testing and its working as i want it to with the above.
<strong>Is there something wrong using it as above?</strong></p>

<p>Thanks</p>
