Reputation: 8975
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";
?>
Upvotes: 1
Views: 106
Reputation: 2016
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
Upvotes: 3
Reputation: 2339
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
Upvotes: 1