Page 1 of 1

end php script

Posted: Tue Mar 14, 2017 8:30 pm
by mister_v
Hi,

I would like to know what the best way is to end a script,
in the middle?
Lets say after a if-statement .

thanks,

Re: end php script

Posted: Wed Mar 15, 2017 7:10 pm
by chris
You can use exit

Code: Select all

//exit program normally
exit;
exit();
exit(0); //this program ran successfully/without errors"

//exit with an error code
exit(1);
exit("error text"); //octal
You can also use die(), wich is the same but mostly used with a error code

Code: Select all

die("There was a fatal error");