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!

cPanel/WHM API help

Discussion in 'General Discussion' started by webadpro, Feb 26, 2006.

  1. webadpro

    webadpro Member

    Joined:
    Dec 7, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    151
    Hi,

    I was just wondering, can you run a string in a function or does it has to be standalone.

    I'm using whmreq function.

    What I mean extactly is this:

    If I write my coding and at the end I add:

    $bob = $test->adding($host,$user,$accesshash);

    It runs adding and adds the package, like it suppose to do,
    but if I add that line in a function... nothin works.

    Please help,
    I'm in big need.

    Regards,
    Pat
     
  2. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    8
    Trophy Points:
    193
    Two words .... "variable scope"
     
  3. webadpro

    webadpro Member

    Joined:
    Dec 7, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    151
    Could you explain a bit more please!?

    Regards,
    Pat
     
  4. webadpro

    webadpro Member

    Joined:
    Dec 7, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    151
    any more help?
     
  5. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    166
    The function doesn't have access to the variables $test, $host, $user, and $accesshash etc.

    You can use the global keyword to get the vars from the global scope

    PHP:
    <?
    function 
    xxx(){
    global 
    $test$host$user$accesshash;
    $bob $test->adding($host,$user,$accesshash);

    }
    ?>

    or pass in the vars as arguments to the function:
    PHP:
    <?
    function 
    xxx($test$host$user$accesshash){
    $bob $test->adding($host,$user,$accesshash);

    }
    ?>
    But you should read up on your variable scope. It's a basic part of programming PHP.
     
  6. webadpro

    webadpro Member

    Joined:
    Dec 7, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    151
    Thanks Everyone!

    It's finally Working!

    BIG THANKS!
     
    #6 webadpro, Mar 2, 2006
    Last edited: Mar 2, 2006
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