Page 1 of 1
calling a function within a function [solved]
Posted: Tue Dec 04, 2007 6:53 am
by php3ch0
How can I do this or is it not possible?
Code: Select all
function dosomething() {
echo "something";
}
function dosomethingelse() {
dosomething();
}
Posted: Tue Dec 04, 2007 7:01 am
by Jaxolotl
of course it is possible and a common way to combine functions. Remember to pray attention to the availability of the variable you will use (unless you pass them or you set them as global inside the function, the variables will be only locally available if declared/assigned inside the function)
http://php.net/manual/en/language.functions.php
Posted: Tue Dec 04, 2007 7:06 am
by webspider
Are you talking about recursion function?
Posted: Tue Dec 04, 2007 7:23 am
by Jaxolotl
webspider wrote:Are you talking about recursion function?
The example written by
php3ch0 seems a "scope" question. I mean, calling a foreign function inside another function. Recursion would be calling the function inside itself.
Posted: Tue Dec 04, 2007 7:24 am
by php3ch0
yes it was calling a foreign function in another function.
Thanks worked a treat.
Posted: Tue Dec 04, 2007 7:43 am
by webspider
yes I missed the "else"
Code: Select all
function dosomethingelse()
{
dosomething();
}
It was just calling a function from a function.