PHP return statements are not used unless they are in functions.
Share another role of the PHP return Statement, which is a wonderful way to use in the bbPress code.
I always thought that return can only appear in the function until I read the bbPress code:
<? Phprequire_once ('./bb-load.php'); bb_repermalink (); // The magic happens here. if ($ self) {if (strpos ($ self, '. php ')! = False) {require ($ self);} else {require (BB_PATH. 'profile-base. php');} // www. jb51.netreturn ;}
Can return still appear outside of the function? This is unimaginable in the C language.
Check the PHP Manual: if a return statement is called in a function, the execution of the function is immediately ended and its parameters are returned as the function value. If it is called globally, the current script file stops running.
Problems with using the return statement in PHP
Return is returned.
Echo is the output. You can also print
Return is not an output,
The return Statement in php Functions
Yes. According to the logical relationship, when a return statement is executed, the return Statement is returned and the subsequent statement is not executed. If a return statement is not executed, the subsequent statements may be executed.
However, the second return in this program is useless and will never be executed.