Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 TJMAudio

TJMAudio
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 14 October 2006 - 05:13 PM

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.
:: My Site ::
Feel free to critique...

#2 Stooney

Stooney
  • Members
  • PipPipPip
  • Advanced Member
  • 1,093 posts
  • LocationLas Cruces, NM

Posted 14 October 2006 - 05:24 PM

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

<embed src='.wav' autostart='true' loop='false'
width='2' height='0'>
</embed>
i found that ERMMMMM thats called PHP!!!!


#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 October 2006 - 06:22 PM

If you mean a function within a function:
function myfuncA() {
    // code for function A

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

}
Then yes. However you have to called function A first before using function b. Example:
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();





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users