exit()
is valid,but
exit()
echo 1;
Will fail.
Why?
exit()
is valid,but
exit()
echo 1;
Will fail.
Why?
The first is correct syntax , the later isn't. If more than one command is provided, they have to be separated via ;
. echo 1
wouldn't be executed anyway.
The semicolon terminates a statement, although it's not required if it's the last statement.
This:
exit()
will work only if it is at the end
But
exit()
echo 1;
In this case it is not on the end.
You can do exit(1); to set the status/severity of the reason for using it. Or you can use exit("1"); and it will print the string. The difference being that the first is an integer and the second is a string.