|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28331 Fatal Errors
Submitted: 2004-05-09 04:13 UTC Modified: 2015-03-21 20:15 UTC
Avg. Score:4.9 ± 0.3
Reproduced:9 of 10 (90.0%)
Same Version:5 (55.6%)
Same OS:3 (33.3%)
From: microcamers at hotmail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: * OS: Irrelevant
Private report: No CVE-ID: None
 [2004-05-09 04:13 UTC] microcamers at hotmail dot com
Can you make it possible to make most fatal errors catchable, such as the ones for undefined functions, classes, redefined things and so on. Generally make it so any error that can be caught can be caught.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-07 19:54 UTC] paul dot ossenbruggen at websidestory dot com
It would be especially useful to be able to catch a missing 
function or method errors in an eval() statement with 
arbitrary code. This can be used in a unit test situation 
where you want the script to continue to complete other tests.
 [2012-02-21 13:54 UTC] lang at b1-systems dot de
+1 from my side. Mixing and matching expressions with fatals and return-0-checks is evil and clutters the code. 


At least methods on non-objects can happen when you come from javascript or similar scripting communities which encourage chaining/nesting calls to more or less human-readable commands like

$granny_name = $baby->getMother()->getMother()->getName();

In PHP you would rather do

$mother = $baby->getMother();

if ($mother) {
    $granny = $mother->getMother();
    if ($granny) {
        $granny_name  = $granny->getName();

A comment would be welcome if such a patch would generally be apreciated or you want to keep this fatal as a design decision. If the change is welcome, i'll see if I can provide a patch.
 [2015-01-08 22:57 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Windows XP +Operating System: Irrelevant -PHP Version: 5CVS-2004-05-09 (dev) +PHP Version: *
 [2015-01-08 22:57 UTC]
This would be fixed by this RFC, if adopted:
 [2015-03-21 20:15 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2015-03-21 20:15 UTC]
Implemented in PHP 7.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 14:01:23 2021 UTC