note 38512 deleted from functions by didou
| From: | didou@php.net | Date: | Thu, 25 Dec 2003 10:14:26 +0000 |
| Subject: | note 38512 deleted from functions by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62445@lists.php.net to get a copy of this message | ||
Note Submitter: arjini@mac.com
----
When building a class that has functions inside functions, the behavior and function scope of that
inner function isn't quite what you would expect.
This works.
<?
class blarg
{
function test()
{
function echo_hoorah()
{
echo 'hoorah!';
}
}
function another_test()
{
echo_hoorah();
}
}
$blarg = new blarg;
$blarg->test();
// hoorah!
?>
But this doesn't.
<?
class blarg
{
function test()
{
function echo_hoorah()
{
echo 'hoorah!';
}
$this->another_test();
}
function another_test()
{
echo_hoorah();
}
}
$blarg = new blarg;
$blarg->test();
// hoorah!
?>
But this doesn't.
<?
class blarg
{
function test()
{
function echo_hoorah()
{
echo 'hoorah!';
}
$this->another_test();
}
function another_test()
{
$this->echo_hoorah();
}
}
$blarg = new blarg;
$blarg->test();
// Call to undefined function 'echo_hoorah';
?>
I would have expected the opposite.