note 80305 added to control-structures.if
| From: | redrobinuk at aol dot com | Date: | Wed, 09 Jan 2008 10:54:05 +0000 |
| Subject: | note 80305 added to control-structures.if | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134966@lists.php.net to get a copy of this message | ||
This is aimed at PHP beginners but many of us do this Ocasionally...
When writing an if statement that compares two values, remember not to use a single = statement.
eg:
<?php
if ($a = $b)
{
print("something");
}
?>
This will assign $a the value $b and output the statement.
To see if $a is exactly equal to $b (value not type) It should be:
<?php
if ($a == $b)
{
print("something");
}
?>
Simple stuff but it can cause havok deep in classes/functions etc...
----
Server IP: 64.71.164.2
Probable Submitter: 195.93.21.37
----
Manual Page -- http://www.php.net/manual/en/control-structures.if.php
Edit -- https://master.php.net/note/edit/80305
Del: integrated -- https://master.php.net/note/delete/80305/integrated
Del: useless -- https://master.php.net/note/delete/80305/useless
Del: bad code -- https://master.php.net/note/delete/80305/bad+code
Del: spam -- https://master.php.net/note/delete/80305/spam
Del: non-english -- https://master.php.net/note/delete/80305/non-english
Del: in docs -- https://master.php.net/note/delete/80305/in+docs
Del: other reasons-- https://master.php.net/note/delete/80305
Reject -- https://master.php.net/note/reject/80305
Search -- https://master.php.net/manage/user-notes.php