But the OP says "function is defined inside a different function". Your
theories to a solution don't fit that problem.
"tamouse mailing lists" <[email protected]> wrote in message
news:cahuc_t-416_-lpcn3mo8qqxwrh4pnq5fmwouhwpdk+hmkgh...@mail.gmail.com...
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
<[email protected]> wrote:
Where is name_of_a_different_function defined? If it is somewhere in
the same file as name, that shouldn't be a problem, provided it is
defined in the same namespace/scope as name. If it is defined in a
different file, you need to include that file before you make the echo
statement.
For example:
function func1 ($flag1, $flag2) {
# blah blah
echo func2($flag1, $flag2);
}
function func2 ($flag1, $flag2) {
#blah blah
return "some string value";
}
in the same file should be just fine. It doesn't really matter what
order func1 and func2 are declared in.
However, if func2 is defined in some_other_file.php, you need to
include it in this_file.php (where func1 is defined) first:
this_file.php:
include('some_other_file.php');
function func1 ($flag1, $flag2) {
#blah blah
echo func2 ($flag1, $flag2);
}
some_other_file.php:
function func2 ($flag1, $flag2) {
#blah blah
return "some string value";
}
If func2 is a method for an object/class, you'll have to access it
that way in func1:
this_file.php:
include('MyClass.php');
function func1 ($flag1, $flag2) {
# blah blah, instantiate object?
$myobj = new MyClass();
echo $myobj->func2 ($flag1, $flag2);
}
MyClass.php:
class MyClass
{
function func2 ($flag1, $flag2) {
#blah blah
return "some string value";
}
}
But the OP says "function is defined inside a different function". Your
theories to a solution don't fit that problem.
(Sorry you all had to read thru so much stuff just to get to my one-line
response.)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php