You can use alternate "if statement" syntax within a return statement itself:
<?php
// Return the minimum of two numbers
function min($a, $b){
return $a < $b ? $a : $b;
}
?>
![]() | return如果在一个函数中调用 return() 语句,将立即结束此函数的执行并将它的参数作为函数的值返回。return() 也会终止 eval() 语句或者脚本文件的执行。 如果在全局范围中调用,则当前脚本文件中止运行。如果当前脚本文件是被 include() 的或者 require() 的,则控制交回调用文件。此外,如果当前脚本是被 include() 的,则 return() 的值会被当作 include() 调用的返回值。如果在主脚本文件中调用 return(),则脚本中止运行。如果当前脚本文件是在 php.ini 中的配置选项 auto_prepend_file 或者 auto_append_file 所指定的,则此脚本文件中止运行。 更多信息见返回值。
![]()
jasper at jtey dot com
26-May-2006 02:54
You can use alternate "if statement" syntax within a return statement itself:
warhog at warhog dot net
19-Dec-2005 04:28
for those of you who think that using return in a script is the same as using exit note that: using return just exits the execution of the current script, exit the whole execution.
mike at uwmike dot com
07-Dec-2005 01:25
If you have a class file that's getting out of control, you can set it up like so:
11-Aug-2005 10:42
If you like pickles, then it's good for you.
PackCat
11-Jun-2005 09:02
If you return a value that has not been set, or has been unset, the function will return that status instead. So,
24-May-2005 11:44
If you are just wanting to get the current output printed to the browser (and continue execution), use flush().
17-Feb-2003 07:04
Use "exit()" to end all script execution for the current request. For HTTP requests, the response generated to that point will then be sent to the browser.
| ![]() |