php function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • go4vivek
    New Member
    • Jan 2008
    • 4

    #1

    php function

    Sir,
    i want to know that can i directly call a function which is define with in the function
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    Originally posted by go4vivek
    Sir,
    i want to know that can i directly call a function which is define with in the function
    Hi,

    Can I just check what you mean? It sounds like you have a php function call it functionA inside which is a second function call it functionB. You then want to call functionB from within functionA

    Psuedo Code
    [php]
    function functionA()
    {
    // do something, process some data whatever
    $value = functionB() ;
    function functionB()
    {
    // sub-processing
    return $value;
    } // end functionB
    }// end functionA
    [/php]

    Why would you need to nest the functions like this? You can call one function from another, sure but they are separate functions and should not be nested one inside the other. This would make the code very confusing.

    I would develop two functions, they can be in the same php file and then call them from code as needed, you can call one function from within another. I would also recommend using classes if there are lots of functions in one file.

    Cheers
    nathj

    Comment

    Working...