Jump to content

Archived

This topic is now archived and is closed to further replies.

TJMAudio

Is it possible to call a function inside of another function?

Recommended Posts

I have a function that checks to make sure everything in the form is valid and filled out and I want to make it so if all passes, then it calls another function to create the user account... is this possible?  Do I have to create a class to do this?

Thanks.

Share this post


Link to post
Share on other sites
Its possible.  ex:

function check()
{
    //checks stuff
    //if(all is ok){  make_account($user, $pass); }
}

function make_account($user, $pass)
{
    //makes account
}


you can call function from function from function over and over.  :D

Share this post


Link to post
Share on other sites
If you mean a function within a function:
[code]function myfuncA() {
    // code for function A

    function myfuncB() {
        // code for function B
    }

}[/code]
Then yes. However you have to called function A first before using function b. Example:
[code]function myfuncA() {

    echo "Called function A<br />";

    function myfuncB() {
        echo "Called function B";
    }

}

// call function a first:
myfuncA();

// now we can use function b
myfuncB();
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.