php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11196 'Cannot redeclare' in nested functions
Submitted: 2001-05-30 11:19 UTC Modified: 2001-06-01 08:03 UTC
From: flying at dom dot natm dot ru Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: flying at dom dot natm dot ru
New email:
PHP Version: OS:

 

 [2001-05-30 11:19 UTC] flying at dom dot natm dot ru
Environment:
 - Windows 2000 Server
 - Apache v1.3.19
 - PHP v4.0.5 (Win32 binaries from www.php.net)

Following script falls with error message:
Fatal error: Cannot redeclare innerfunc() in test.php line 4

-----------------------------------------------
<?php
function outerFunc()
{
    function innerFunc()
    {
        echo "Into innerFunc()<br>";
    }
    echo "Entering outerFunc()<br>";
    innerFunc();
    echo "Leaving outerFunc()<br>";
};

outerFunc();
outerFunc();
?>
-----------------------------------------------

Crash appears at second function call. 

Bug is 100% reproducible in PHP v4.0.4 and v4.0.5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-30 11:42 UTC] sniper@php.net
not a bug. You can't redeclare functions.
(you're calling outerFunc() twice)

--Jani

 [2001-06-01 08:03 UTC] flying at dom dot natm dot ru
So, it means that you have a bug in documentation in this case.
 Here is a small piece of text from functions.html:

-----------------------
Any valid PHP code may appear inside a function, even <b>other functions</b> and class definitions.
-----------------------

 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC