Re: whats wrong with this?
| From: | Richard Lynch | Date: | Fri, 30 Aug 2002 23:59:56 +0000 |
| Subject: | Re: whats wrong with this? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114726@lists.php.net to get a copy of this message | ||
> if($day = $system_day){
>
>the problem i am experiencing is that it seems the "if" statement is setting
>the $day value to equal $system_day instead of comparing their values....
>if i add
That's because you have only one = sign there.
= by itself does the assignment (setting a value)
== does comparison.
Sometimes, you do *both* an assignment and "test" the "answer" in a single
line like this:
if ($row = mysql_fetch_row($result)){
Here, the = does an "assignment" (sets the value) and then the *VALUE* is
tested to see if there is something there or not.
The = sign is only roughly similar to = in Mathematics.
Or, perhaps it would be better to say that:
= is like "Suppose x = 5. Then..."
== is like "Is x = 5?"
--
Like Music? http://l-i-e.com/artists.htm