echo "world";
?>
Syntax format: void means no return value.
void exit ([ string $status ] )
void exit ( int $status )
If status is a string, this function prints the status just before exiting.
If status is a string, this function prints status before the script exits.
If status is an integer, that value will also be used as the exit status. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.
If status is an integer, this integer will be used as the exit status. Exit status should be from 0 to 254, exit status 255 is reserved by PHP and is prohibited from use. Status 0 is used to indicate successful termination of the procedure.
2. Usage of return language structure
Function: Terminate the execution of the function and return a value from the function
3.break and continue
Used in for, foreach, while, do..while or switch structures.
break ends the execution of the current for, foreach, while, do..while or switch structure.
break can accept an optional numeric parameter to determine how many loops to break out of.
Code:
$arr = array ('one', 'two', 'three', 'four', 'stop', 'five');
while (list (, $val) = each ($arr)) {
if ($val == 'stop') {
break;
}
echo "$val
n";
}
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5
n";
break 1;
case 10:
echo "At 10; quitting
n";
break 2;
default:
break;
}
}
?>
continue is used in a loop structure to skip the remaining code in this loop and start executing the next loop of this loop structure.
Note: Note that in PHP the switch statement is considered a loop structure for continue purposes.
continue accepts an optional numeric parameter to determine how many loops to skip to the end of the loop.
Code:
while (list ($key, $value) = each ($arr)) {
if (!($key % 2)) { // skip odd members
continue;
}
do_something_odd ($value);
}
$i = 0;
while ($i++ < 5) {
echo "Outer
n";
while (1) {
echo " Middle
n";
while (1) {
echo " Inner
n";
continue 3;
}
echo "This never gets output.
n";
}
echo "Neither does this.
n";
}
?>
http://www.bkjia.com/PHPjc/477121.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477121.htmlTechArticlereturn, break and contiue are language structures, just like if statements, but exit is a function. 1.exit function Function: Output a message and terminate the current script Output a message...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31