Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Passing $xmlapi to function?

Discussion in 'cPanel Developers' started by dotcomma, Sep 25, 2011.

  1. dotcomma

    dotcomma Registered

    Joined:
    Sep 25, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Website Owner
    Hi all, this is newbie, but and just a PHP question more than anything.. so.. here goes
    in PHP, how can I pass the $xmlapi object to functions?

    function initxmlapi(){
    $ip = "asdf.com";
    $account = "asdf";
    $account_pw = "abc123";

    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port(2083);
    $xmlapi->password_auth($account, $account_pw);
    $xmlapi->set_output('xml');
    return $xmlapi;
    }
    how can i return the xmlapi object? can i do this? should i even do this?

    i want to then pass this to a function by:

    $xmlapi = initxmlapi();

    function createEmailAccount($xmlapi){
    // all the variables declared here
    $xmlapi->api1_query( $account, "Email", "addpop", array("blabla", "blabla", "1", "asdf.com") );
    }

    this works when i don't put them in functions.. but when I do separate them out, it doesn't work. any advice?

    Thanks
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice