so I'm trying to prevent fatal errors from stopping my script from running
so I set error report to 0:
error_reporting(0);
then I added some junk code afterwards..
junk code~~~~trololololololol
However, PHP ends up returning parse error nonetheless:
Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE) in etc
is there a way to prevent PHP from ceasing to execute when there are parse errors or is this a hopeless endeavor?
is there a way to prevent PHP from ceasing to execute when there are parse errors or is this a hopeless endeavor?
Yes, that's hopeless. It's impossible to resume execution after junk was found, there just isn't any predictable state left for the compiler to adhere to. It might be missing random functions, variable definitions and what not, so all it can logically do is stop working.
You can suppress the error but not force it to continue working after the digital equivalent of a violent heart attack.
You can't. PHP first reads the text in your script from beginning to end (parses it) and converts it into some form of low-level bytecode that can be executed. If it fails to parse, then there's no executable code at all and it can only fail.
With runtime errors, your code is already executing and PHP already knows if you've got some way to handle that error. But with a parse error, there's no program there to begin with.
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