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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

calling a function from within a function

  • 15-04-2003 10: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,196 ✭✭✭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