I know nothing about C, C++ or any lower level than PHP. I take a glance into Codeigniter 3 codes at github and found it's added exit status code constants, i.e we can do:
exit(EXIT_DATABASE)
means exit(8)
or exit(EXIT_UNKNOWN_CLASS)
means exit(5)
what is differ between
echo 'Configuration file not found';
exit(3);
and just
exit('Configuration file not found');
?
What is the purpose of using exit(integer)
in php ? it doesn't print anything, does it? I also check the docs and google some but still not get it clear. How to make use of this? where i can get reference about this ?
Thanks.
It gives the caller a hint as to what the outcome of running your script is.
This can be useful in php if you are running a script with exec
or system
and you need to behave differently based on the outcome of running the script.
<?php
$output = array();
$error = null;
exec("/path/to/php cleanData.php", $output, $error);
if ($error){
Logger::log($error, $output);
die("Sorry I was Unable to Clean the Data\n");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With