Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

calling a function from within a function

  • 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, Registered Users 2 Posts: 4,119 ✭✭✭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