Jump to content

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.
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
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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.