Linked Questions

1 vote
2 answers
2k views

is it possible to catch fatal error php on include file? [duplicate]

Here's what I want to do just if a fatal error is in the file I don't want the script to halt execution try { require "somethin.php" } catch(...) {} Would some method of file_get_contents() and ...
y2k's user avatar
  • 65.8k
3 votes
2 answers
3k views

Is there a way to catch Fatal error in PHP? [duplicate]

Possible Duplicate: How do I catch a PHP Fatal Error I have this line of PHP code: thisFunctionDoesNotExist(); And it stops script execution with: Fatal error: Call to undefined function I ...
Josef Sábl's user avatar
  • 7,683
0 votes
3 answers
1k views

Providing a callee response to a "call to undefined method" error? [duplicate]

I'm learning my way into some more advanced programming with PHP. I've seen that calling an non-existent method produces "call to undefined method" error. PHP being quite flexible is there a ...
James P.'s user avatar
  • 19.5k
1 vote
1 answer
931 views

Catch the PHP private __constructor fatal error and throw an exception PHP? [duplicate]

I would like to ask if this is possible: I have a class with a private constructor which of course throws a fatal error if I try to instantiate that class from an invalid context (outside the class), ...
tonix's user avatar
  • 6,861
0 votes
1 answer
334 views

How to catch syntax errors in included files in PHP? [duplicate]

I'm developing a plugin system, which of course needs to include the plugin files. So far everything works very well - exceptions get catched etc. But my very last wish would be to even be safe from ...
Robert's user avatar
  • 431
1 vote
1 answer
210 views

PHP ignores custom error handler [duplicate]

Possible Duplicate: How do I catch a PHP Fatal Error I want to create a custom error handler but PHP ignores it still uses the built in error handler. The example below gives a built in fatal ...
mauzilla's user avatar
  • 3,582
0 votes
1 answer
366 views

PHP 7.4 unable to catch Fatal error: Cannot redeclare <function> [duplicate]

I loved the introduction of the \Throwable interface and the ability to convert legacy Errors warnings and notices into catchable errors. This is how I have rolled ever since: //convert errors to ...
Brad's user avatar
  • 880
1 vote
0 answers
138 views

How to catch the Fatal Error in PHP? [duplicate]

I'm facing with the Fatal error: Maximum execution time of 30 seconds exceeded. I'm trying to catch this error and show the error message to user but it seems that "try...catch..." in PHP can't ...
Tho Nguyen's user avatar
0 votes
1 answer
114 views

How to produce proper json error response for php fatal error in Laravel 8+ [duplicate]

I need to produce some proper custom error response in json format when I receive php fatal error instead of standard 500 in Laravel 8+. How can I achieve the this outcome.
Rajesh's user avatar
  • 27
0 votes
0 answers
60 views

How to add a 'Content-Type' header to an HTTP response with PHP fatal error in IIS? [duplicate]

I use a stack of technologies Windows 10, web server IIS 10, RDBMS 'MySQL' 8.0, PHP 8.1.10. My question was considered a duplicate of the following question: 'Trouble with UTF-8 characters; what I ...
Ilya Chalov's user avatar
1 vote
0 answers
50 views

Errors not being caught by "try" block [duplicate]

I was expecting this page to render as the string "TryErrorFinally", but the result is just the string "Try". Do I need to do something else to see the exception generated by calling the non-existent ...
gcbenison's user avatar
  • 11.9k
1 vote
0 answers
43 views

How to customize some default PHP error message thrown to user [duplicate]

I encounter the situation as follows: My system sometimes gets default two specific errors and display to user's screen. But now, my users would like to display these kind of error messages in a ...
Nhat Ho's user avatar
  • 21
0 votes
0 answers
28 views

Get /print fatal error message in PHP [duplicate]

How can I retrieve the message-only from a fatal error message in php store it as a variable. I'm running a script which I believe has some custom error reporting on it when it runs. When the ...
user3143218's user avatar
  • 1,786
84 votes
8 answers
93k views

How to catch the fatal error: Maximum execution time of 30 seconds exceeded in PHP

I've been playing around with a system I'm developing and managed to get it to cause this: Fatal error: Maximum execution time of 30 seconds exceeded It happened when I was doing something ...
ingh.am's user avatar
  • 26.5k
73 votes
10 answers
82k views

How can I get php to return 500 upon encountering a fatal exception?

PHP fatal errors come back as status code 200 to the HTTP client. How can I make it return a status code 500 (Internal server error)?
Mike's user avatar
  • 741

15 30 50 per page
1
2 3 4 5
8