0

I'm trying to find out how I would put a PHP error into a variable to display.

Similar to the mysql_error(); I'd like to be able to have displayed the error that PHP gives?

I'm using json_encode to send the testing user back a value from the requested PHP page but if an error happens I can get the mysql_error(); fine but how would I get the php error?

I've tryed $phpError = error_reporting(); but I just get error 22527 like this same Error. I just want to put the php error into a string to send back to the user.

0

3 Answers 3

3

You can write your own error handler: http://www.php.net/manual/en/function.set-error-handler.php And return a json encoded string.

Sign up to request clarification or add additional context in comments.

Comments

0

you can create an custom error handler with set_error_handler and from that point on you can do anything you want

Comments

0

Check out $php_errormsg. I hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.