Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
555 views
in Technique[技术] by (71.8m points)

error handling - How can I tell PHP to dump exceptions as raw text instead of HTML?

When I'm developing my REST API in PHP I'm working with application/json output, so when I get errors while testing in the browser they look like this:

<b>Fatal error</b>: Uncaught exception 'Exception' with message 'PDO caught an error:
array(3) {
  [0]=&gt;
  string(5) &quot;42000&quot;
  [1]=&gt;
  int(1065)
  [2]=&gt;
  string(15) &quot;Query was empty&quot;
}

And it gets worse when I get large stack traces and stuff. So is there a flag I can set telling PHP that I want my errors unescaped and in raw text?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is a php.ini setting called html_errors.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...