when we use return in PHP on global scope, after return, does execution just stop?
or processing will go on?
<?php
if(defined("A")) return;
define("A", true);
echo "Hello";
if(defined("A")) return;
define("A", true);
echo "Hello";
?>
If you want to stop a script, you'd better use exit, because return should be only used in functions !
http://php.net/manual/en/function.return.php
http://php.net/manual/en/function.exit.php
In your case, the script will end as said by the documentation : return will also end the execution of an eval() statement or script file
Output a message and terminate the current script and there are number of examples supporting his answer and absolutely matching the question's context.Your script will be stopped after first return
As documenation says:
If return is called from within the main script file, then script execution ends
exitto stop the further execution..Output a message and terminate the current scriptIf called from the global scope, then execution of the current script file is ended. If the current script file was included or required, then control is passed back to the calling file.But in OP's case execution will be stopped.