Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

calling a function from within a function

Options
  • 15-04-2003 11:25am
    #1
    Closed Accounts Posts: 59 ✭✭


    Hi All,
    I know this is a pretty straightforward procedure!
    That is why I am so puzzled as to why this won't work for me. It's php but it should work the same way as c++ would;
    I have a function called printMenuLevel($var)
    //where $var is an object
    I then have this function:

    function trail($var)
    {
    $thatURL = $var->url;
    echo($thatURL);
    echo("<br>");
    if ($thatURL == $thisURL ){ //this cond defn does not fail!
    printMenuLevel($arr[1]);
    }
    while(list($key, $value)= each($menuLevel->children))
    {
    trail($value);
    }
    }
    trail($arr[1]);

    Any ideas why printMenuLevel is not called
    thanks
    Fi**


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Where does the array $arr come from? From outside the function (in which case it should be declared as global) or it this a typo and you should be refrencing $var?


  • Closed Accounts Posts: 59 ✭✭Fi_C**


    $arr is an array within class var


    $root_menu = new var ( "Home", "piqs.php", $arr = array(
    new var( "Admin", "piqs.htm", array(
    new var ("Manage Tests", ....

    and so on ...

    var is a class :

    class var
    {
    var $title;
    var $url;
    var $children;

    function var ($title, $url, $children=null)
    {
    $this->title = $title;
    $this->url = $url;
    $this->children = $children;
    }
    }

    thanks
    Fi**


  • Registered Users Posts: 4,185 ✭✭✭deadl0ck


    Have you tried putting in some echo statements in the printMenuLevel function to see if it's actually getting into the function ?

    Also, shouldn't you have printMenuLevel($var->arr[1]);

    The code doesn't know what $arr is otherwise


Advertisement