note 101034 added to control-structures.if
| From: | admin at leonard!spamchallis dot com | Date: | Mon, 22 Nov 2010 12:41:01 +0000 |
| Subject: | note 101034 added to control-structures.if | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174245@lists.php.net to get a copy of this message | ||
When using if statements without the curly braces, remember than only one statement will be executed
as part of that condition. If you want to place multiple statements you must use curly braces, and
not just put them on the same line.
<?php
if (1==0) echo "Test 1."; echo "Test 2";
?>
Whereas some people would expect nothing to be displayed, this piece of code will show: "Test
2".
----
Server IP: 69.147.83.197
Probable Submitter: 84.93.192.121
----
Manual Page -- http://www.php.net/manual/en/control-structures.if.php
Edit -- https://master.php.net/note/edit/101034
Del: integrated -- https://master.php.net/note/delete/101034/integrated
Del: useless -- https://master.php.net/note/delete/101034/useless
Del: bad code -- https://master.php.net/note/delete/101034/bad+code
Del: spam -- https://master.php.net/note/delete/101034/spam
Del: non-english -- https://master.php.net/note/delete/101034/non-english
Del: in docs -- https://master.php.net/note/delete/101034/in+docs
Del: other reasons-- https://master.php.net/note/delete/101034
Reject -- https://master.php.net/note/reject/101034
Search -- https://master.php.net/manage/user-notes.php