From:             [EMAIL PROTECTED]
Operating system: FreeBSD
PHP version:      4.0.5
PHP Bug Type:     *Programming Data Structures
Bug description:  Function within a function namespace

I have found that a function within a function takes a global namespace.  Shouldn't 
the inside function declaration remain inside the scope of the outer function?  For 

function add_number($num)
    function add_one($num)
    $num = add_one($num);
    if($num <= 10)
        $num = add_number($num);

I know, why would anyone want to do this?  I'll try to explain how I came about this.

We're writing a content management application.  What I'm trying to do is write a 
function that includes a file that has a function in it.  The file may be included 
more than once on the page depending on the designer's preference.  Say we have an 
include file that generates a "navigation block" on the page.  It has a function 
specific to doing that task.  The nav-block may not appear on every page, so it's 
inefficient to include the function unless I'm going to generate the nav-block.  I 
therefore have to provide the function in the include file along with the html and 
other php code to generate the nav-block when and where I want.  I wrote a function 
which I pass an ID to, which then includes the nav-block file.  But, if I try to put 
another copy of that same nav-block on the same page, I get the "Cannot redeclare..." 
error.  Yes, I could use a class structure, but we are trying to achieve a way of 
programming these "blocks" in the most simplistic way by minizing the amount of php 
knowledge necessary.

If any of this is not clear, I'm willing to go to any length to explain and to find 
out if this can be resolved.  It's pretty important that we can do this.  One of the 
main goals to our software depends on this.


Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to