Another function of the PHP return statement is the return statement.
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' ); } return;}
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.
Alas, the C language is too poisonous.
In PHP, how does return work?
Return is actually not difficult to use. It means return;
If return is executed, the content following the return statement will not be executed;
Return can be a function return value or a null value, depending on your usage, for example:
Function test ($ ){
If ($ a> 10 ){
Return "a> 10 ";
} Else {
Return "a <10 ";
}
$ B = 45;
$ C = $ B-$;
Echo $ c;
}
In this example, when you call this function and then give a number, it returns a string, and the code: $ B = 45;
$ C = $ B-$;
Echo $ c;
Will never be executed
Problems with using the return statement in PHP
Return is returned.
Echo is the output. You can also print
Return is not an output,