NYCPHP Meetup

NYPHP.org

[nycphp-talk] QuickForm / PHP (Zend Engine) Bug - callback function never called

Jayesh Sheth jayeshsh at ceruleansky.com
Thu Mar 17 12:47:10 EST 2005


Hello Dan,

Thanks for your reply. I have boiled down this experience to two test 
cases. In the first case, there is no conditional check, and so the 
call_user_func() succeeds. In the second case, the call to 
call_user_func() fails, simply due to the conditional check. I feel 
there is no logical reason for the inclusion of a conditional check to 
cause call_user_func to fail. Does anyone on this list know if someone 
has deliberately designed PHP this way, and if so, why?

Thanks in advance,

- Jay Sheth

Example 1: call_user_func() succeeds.
--------------------------------------------------------------------------
<?php
    if ( is_callable('echo_echo') )
    {
        echo "<p> echo_echo() is a callable function. </p>";
        call_user_func('echo_echo');
    }
   
    else
    {
        echo "<p> Error: echo_echo() is NOT a callable function. </p>";
    }
   
    function echo_echo()
    {
        echo "<p>This has been outputted by the echo_echo function.</p>";
    }
?>
--------------------------------------------------------------------------

Example 2: call_user_func() FAILS, due to conditional check
--------------------------------------------------------------------------
<?php
define ("IS_TRUE", true);

if ( IS_TRUE )
{
    if ( is_callable('echo_echo') )
    {
        echo "<p> echo_echo() is a callable function. </p>";
        call_user_func('echo_echo');
    }
   
    else
    {
        echo "<p> Error: echo_echo() is NOT a callable function. </p>";
    }
   
    function echo_echo()
    {
        echo "<p>This has been outputted by the echo_echo function.</p>";
    }
}

else
{
    echo "<p>Unfortunately, it's not true.</p>";
}
?>
--------------------------------------------------------------------------




More information about the talk mailing list