Edit report at https://bugs.php.net/bug.php?id=63538&edit=1

 ID:                 63538
 Comment by:         lubosdz at hotmail dot com
 Reported by:        [email protected]
 Summary:            "Call to undefined function" should be catchable
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   any
 PHP Version:        5.5.0alpha1
 Block user comment: N
 Private report:     N

 New Comment:

What about function_exists() ?

set_error_handler(function($errno , $errstr){
    if (!function_exists('there_is_no_me')) {
        function there_is_no_me(){
            echo "Here am I!\n";
        }
    }
});

lubosdz


Previous Comments:
------------------------------------------------------------------------
[2012-11-16 10:13:02] [email protected]

Description:
------------
At the moment, call to undefined function results as "Fatal error". On the 
other hand, it can be easily handled programmatically either by including 
required file or just defining function dynamically.

Test script:
---------------
<?php

set_error_handler(function($errno , $errstr){
    if (strpos($errstr, 'Call to undefined function there_is_no_me()') === 0) {
        function there_is_no_me()
        {
            echo "Here am I!\n";
        }
    }
});

there_is_no_me();


Expected result:
----------------
Here am I!

Actual result:
--------------
Fatal error: Call to undefined function there_is_no_me()


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63538&edit=1

Reply via email to