Reputation: 247
we have forbidden to show errors on our server. But I'd need to show the errors in my script despite it.
I tried this:
<?php
error_reporting(E_ALL);
ini_set("display_errors", "on");
echo "chyba"
echo "nazdárek";
?>
But it is not useful. Thank you for your help.
Upvotes: 0
Views: 110
Reputation: 72366
Your call to error_reporting()
doesn't do anything because it does not run.
There is a missing ;
after the first echo
. I know you know about it, you made the mistake on purpose, to show that error_reporting()
doesn't do what you expect it to do.
It doesn't work this way. The missing semicolumn is a syntax error. The script does not compile, so it does not run. Your call to error_reporting()
is not executed and that means the value of the error_reporting
configuration directive is the one that decides what errors are reported.
You have to fix the syntax errors first, make the script compile & run, and only after that try to trigger a runtime error and see if it is reported back to you. I bet it is.
A runtime error or warning is easy to generate. Try a division by zero, for example.
Upvotes: 1
Reputation: 522510
What you're trying to produce there is a syntax error. This won't work within the same file that you're setting error reporting. The file first needs to be parsed in its entirety. If there's a syntax error in the file, then none of its code will be executed, so no error reporting will be switched on.
Upvotes: 0