PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The following code gives the error "Fatal error: Cannot redeclare bar() (previously declared in /var/www/htdocs/tmp/tmp.php:6) in /var/www/htdocs/tmp/tmp.php on line 5"
I believed that the function bar() would be out of scope. Am I misunderstading something about scope?
Generally though what I need to do is have a function, nested inside a member function of a class, and be able to instantiate that class more than once in a script. Is this possible?
Example 17-3. Functions within functions
<?php
function foo()
{
function bar()
{
echo "I don't exist until foo() is called.\n";
}
}
/* We can't call bar() yet
since it doesn't exist. */
foo();
/* Now we can call bar(),
foo()'s processesing has
made it accessible. */
bar();
?>