I’m building a simple system with a Form with EXE Output 2019.1
When a PHP error (or notice) occour, let’s say at the beginning of the page, it is shown in the usual pop-up AND in the Log file wich I’ve activated.
Tha problem is that when the error occours inside the IF statement raltive to data posted by the form, it return no message, even in the log file there is only “PHP ERROR:”
Obviously this make debug really painful.
Any help would be mutch appreciated.
Have you enabled PHP error log?
Yes I did but, for the errors inside the IF, I get only “PHP ERROR:”
Can you tell us what code you used for that IF statement?
I’ve created a test program to reproduce the problem.
There is only an index.php file whith this code at the beginning:
//if i generate an error here i can see it
//if i generate an error here is blank
and a form like this in the body:
<form id="form1" name="form1" method="post" action="index.php">
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="Submit" />
If I uncomment the first line I get the error, otherwise if I submit the form I receive a blank error.
Have you enabled the PHP error logging in PHP.ini?
As I said
and I still get a blank error…
That’s not what I meant. PHP has its own logging system that is not captured by ExeOutput. If you get a blank page, this means that PHP had an error and returned nothing. Then, you can capture this error in the PHP error log. You have to configure the PHP.INI to enable that PHP logging.
Sorry, I didn’t understand what you meant.
I have now, and it worked! I’ve placed those lines in php.ini:
log_errors = on
error_reporting = 32767
error_log = D:\php_error.log
Now the errors appear also on the page just like any normal web server.
Thank you so much!
Sorry but seem there is still a problem.
If I deactivate de directive “error_log = D:\php_error.log” in php.ini (leaving the other two intact) or set a non existing path, the original problem is still there.
Now, in my test enviroment, this is not much of a problem but in deploiment it IS since I can’t be sure of a path for error log.
There is at least a way to set some sort of default path in php.ini like HEPubStorageLocation?
error_log = C:\Windows\temp\php_errors.log
I had to put this project asiede for a while.
Now I’m back on it and your suggestion worked.
You should check
set_exception_handler functions of PHP.
You don’t need to have error_log enabled in the PHP.ini.
You can directly use these functions in a script file (or in a common included file).
Here is a basic example:
function MyHandler($errno, $errstr, $errfile, $errline, $errcontext)
echo "Following PHP error occured:\n";
$a = ;
$b = ($a + 5); // Following PHP error occured: Undefined offset: 2
This is for soft warnings. For fatal errors and exceptions, you can use the
set_exception_handler in the same way (examples are there on PHP docs).
Of course, this is just an example, and you can do anything with it you want (show to user / log somewhere / etc.).
Thanks for this tip.
This project is debugged and finished, but I will definitely try it for the next project