end php script

All your question about php
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

end php script

Post 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,
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: end php script

Post 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");
Post Reply