• PHP Gotcha!

    From Angus McLeod@VERT/ANJO to All on Sunday, September 24, 2006 14:15:00
    Why can I do:

    <?
    $my_func = "function_name";
    $result = $my_func( $arg1, $arg2, $arg3 );


    but NOT do:

    <?
    $my_ob->func = "function_name";
    $result = $my_ob->func( $arg1, $arg2, $arg3 );
    ?>

    to call function_name() with the apropriate arguments? Do I have to do something to the object-property reference to make it work? Currently I'm doing:

    <?
    $my_ob->func = "function_name";
    $f = $my_ob->func;
    $result = $f( $arg1, $arg2, $arg3 );
    ?>

    which works, but it's nyaaagh!

    ---
    Playing: "Whole lotta love" by "Led Zeppelin"
    from the "Led Zeppelin II" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Solid_Liq@VERT/CARSO to Angus McLeod on Wednesday, September 27, 2006 00:56:00
    Re: PHP Gotcha!
    By: Angus McLeod to All on Sun Sep 24 2006 15:15:00

    Why can I do:

    <?
    $my_func = "function_name";
    $result = $my_func( $arg1, $arg2, $arg3 );
    ?>

    but NOT do:

    <?
    $my_ob->func = "function_name";
    $result = $my_ob->func( $arg1, $arg2, $arg3 );
    ?>

    to call function_name() with the apropriate arguments? Do I have to do something to the object-property reference to make it work? Currently I'm doing:

    <?
    $my_ob->func = "function_name";
    $f = $my_ob->func;
    $result = $f( $arg1, $arg2, $arg3 );
    ?>

    which works, but it's nyaaagh!

    I don't really use PHP (I'm aa C++ coder), but my guess is what's happening
    is the PHP interpreter is trying to dereference the function pointer against my_obj's class, rather than looking for a global function to call.

    ---
    þ Synchronet þ CarSo BBs þ Beverley, UK þ telnet://carso.synchro.net