php.net |  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
Votes:10
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 - 12 = ?
Subscribe to this entry?

 
 [2004-05-09 04:13 UTC] microcamers at hotmail dot com
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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. 

Rationale:

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] ajf@php.net
-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] ajf@php.net
This would be fixed by this RFC, if adopted: https://wiki.php.net/rfc/engine_exceptions_for_php7
 [2015-03-21 20:15 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2015-03-21 20:15 UTC] nikic@php.net
Implemented in PHP 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC