Let's talk about the use of the Exit function.
Function: Outputs a message and terminates the current script.
If a text contains multiple scripts to end, exit exits the current script.
For example, a PHP text includes code, then the output is world.
<%
echo "Hello";
Exit
?>
echo "World";
?>
Syntax format: Void indicates no return value.
void exit ([string $status])
void exit (int $status)
If status is a string, this function prints the status before the script exits.
If the status is an integer, the integer will be used as the exit state. Exit status should be from 0 to 254, exit status 255 is reserved by PHP and is forbidden to use. Status 0 is used to indicate a successful termination program.
The use of the return language structure
Function: Terminates the execution of the function and returns a value from the function
Break and continue used in For,foreach,while,do. The while or switch structure.
Break ends Current For,foreach,while,do: The execution of the while or switch structure.
Break can accept an optional numeric parameter to decide to jump out of a few loops.
Code:
Copy CodeThe code is as follows:
$arr = Array (' One ', ' one ', ' one ', ' 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
}
}
?>
The Continue is used in the loop structure to skip the remaining code in this loop and begin the next loop of the loop structure.
Note: Notice that the switch statement in PHP is considered a looping structure for continue purposes.
Continue accepts an optional numeric parameter to decide to skip a few loops to the end of the loop.
Code:
Copy CodeThe code is as follows:
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";
}
?>
Note: This paragraph of the article from the Internet, the source is unknown
http://www.bkjia.com/PHPjc/325167.html www.bkjia.com true http://www.bkjia.com/PHPjc/325167.html techarticle Let's talk about the use of the Exit function. Function: Outputs a message and terminates the current script. If a text contains multiple scripts to end, exit exits the current script. than ...