Home >Backend Development >PHP Problem >What does php return mean?

What does php return mean?

藏色散人
藏色散人Original
2021-06-15 09:08:312957browse

php return means return, which means that when the program encounters a return statement, the following statements will not be executed, and the program will return directly; if the return statement is called in a function, it will end immediately Executes this function and returns its arguments as function values.

What does php return mean?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What does php return mean?

The meaning of return is that when the program encounters the return statement, the following statements will not be executed, and the program will return directly.

If return() is called in a function statement that will immediately end the execution of this function and return its parameters as the function's values. return() also terminates the execution of the eval() statement or script file.

If called in the global scope, the current script file aborts running. If the current script file is include()ed or require()ed, control is returned to the calling file. Additionally, if the current script is include()ed, the return() value will be treated as the return value of the include() call. If return() is called in the main script file, the script aborts. If the current script file is specified by the configuration option auto_prepend_file or auto_append_file in php.ini, the script file is aborted.

Example:

<?php
function min($a, $b){
return $a < $b ? $a : $b;//这里是做为函数返回值,下面的语句不再执行了
$a++;
}
?>
a.php
<?php
include("b.php");
echo "a";
?>
b.php
<?php
echo "b";
return;
echo "c";//这里将不被执行
?>

The above result will output ba

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does php return mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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