Jump to content

Passing object as arg to function


BuildMyWeb

Recommended Posts

    function chk_error($site_mode, $obj)
    {
        if( $site_mode == 'dev' )
        {
            echo'Error : ('. $obj->errno .') '. $obj->error;
        }
    }

chk_error($site_mode, $stmt);

the above is not working for me.  it echos out the text but no values for errno and error.  what am i doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/292899-passing-object-as-arg-to-function/
Share on other sites

Have you verified that $stmt is an object and that it has properties for errno and error before you pass it to the function?

 

 

    function chk_error($site_mode, $obj)
    {
        if( $site_mode == 'dev' )
        {
            echo'Error : ('. $obj->errno .') '. $obj->error;
        }
    }
 
var_dump($stmt); //Let't verify what $stmt is and what it contains
chk_error($site_mode, $stmt);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.