I think the guide is very obvious that you can look at this example
//exit program normally exit; exit(); exit(0); //exit with an error code exit(1); exit(0376); //octal
It is used to exit the program from the console either with an error or without it, so you can track them, and it is exaclty similar to the die() function.
If the status is an integer, this value will be used as the exit status, and not for printing. Exit statuses must be in the range of 0 to 254, exit status 255 is reserved by PHP and should not be used. State 0 is used to complete the program successfully.
As you said, the function also allows you to directly print your error if you use it with string instead of an integer
If the status is a string, this function prints the status before exiting.
Link
Fabio
source share