Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    16

    Default cPanel/WHM API help

    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. #2
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    Two words .... "variable scope"

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    16

    Default

    Could you explain a bit more please!?

    Regards,
    Pat

  4. #4
    Member
    Join Date
    Dec 2005
    Posts
    16

    Default

    any more help?

  5. #5
    Member
    Join Date
    Apr 2003
    Posts
    479

    Default

    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 Code:
    <?
    function xxx(){
    global 
    $test$host$user$accesshash;
    $bob $test->adding($host,$user,$accesshash);

    }
    ?>

    or pass in the vars as arguments to the function:
    PHP Code:
    <?
    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. #6
    Member
    Join Date
    Dec 2005
    Posts
    16

    Default

    Thanks Everyone!

    It's finally Working!

    BIG THANKS!
    Last edited by webadpro; 03-02-2006 at 04:11 PM.

Similar Threads & Tags
Similar threads

  1. cpanel api from WHM
    By broncha in forum cPanel Developers
    Replies: 13
    Last Post: 07-20-2009, 04:59 PM
  2. WHM / cPanel API
    By paulipv in forum cPanel Developers
    Replies: 9
    Last Post: 07-09-2009, 03:30 PM
  3. cPanel/WHM API?
    By hb-travisbell in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 11-26-2006, 06:42 PM
  4. cPanel / WHM API for PHP5
    By Spiral in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 10-18-2006, 02:54 PM
  5. Cpanel/Whm API
    By farshad_s3 in forum cPanel and WHM Discussions
    Replies: 17
    Last Post: 09-17-2004, 01:14 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube