note 85083 added to control-structures.break
| From: | Anonymous at osu1 dot php dot net | Date: | Thu, 14 Aug 2008 04:54:19 +0000 |
| Subject: | note 85083 added to control-structures.break | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143480@lists.php.net to get a copy of this message | ||
The previous note has a somewhat stupid author: why didn't you put an example?
If I got it right, "case"s in "switch"es always need a "break".
So this switch ...
<?php
switch ( $i ) {
case '1': // Works
echo "$i=1";
break;
case '2': // Works
require( 'include1.inc' );
break;
case '3': // Doesn't work
require( 'include2.inc' );
break;
case '4': // Doesn't work, same reason
require( 'include2.inc' );
default: // Works
echo "$i";
}
?>
... has a problem in case "4" in that it doesn't have a "break" and this
file...
include2.inc:
<?php
echo "$i";
break;
?>
... has a problem in that it has a "break" that is not in a "control structure"
(like while, for...).
In the same way, although "include2.inc" is "include"d (obvioulsy) in the
<?php ?> script (of main.php), it still need another <?php ?> to wrap its content.
Likewise,
main.php
<?php
echo "<div>This div is generated by php</div>\n";
include 'file.php'; ?>
echo "<div>This div is also generated by php</div>\n";
file.php:
<div>This is an old static HTML div.</div>
... doesn't require "file.php" content to start with "?>" (exit php) and
end with "<?php" (go back to line 3 of main.php). This would FAIL.
(See strange structure ALWAYS fail"?>!)
Does this really need documentation?
----
Server IP: 85.196.20.153
Probable Submitter: 85.75.172.235
----
Manual Page -- http://www.php.net/manual/en/control-structures.break.php
Edit -- https://master.php.net/note/edit/85083
Del: integrated -- https://master.php.net/note/delete/85083/integrated
Del: useless -- https://master.php.net/note/delete/85083/useless
Del: bad code -- https://master.php.net/note/delete/85083/bad+code
Del: spam -- https://master.php.net/note/delete/85083/spam
Del: non-english -- https://master.php.net/note/delete/85083/non-english
Del: in docs -- https://master.php.net/note/delete/85083/in+docs
Del: other reasons-- https://master.php.net/note/delete/85083
Reject -- https://master.php.net/note/reject/85083
Search -- https://master.php.net/manage/user-notes.php