php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9064 Functions inside functions cause errors if the outer function is called twice.
Submitted: 2001-02-01 22:18 UTC Modified: 2001-02-02 04:14 UTC
From: chriskl at familyhealth dot com dot au Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: FreeBSD 4.2-STABLE
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chriskl at familyhealth dot com dot au
New email:
PHP Version: OS:

 

 [2001-02-01 22:18 UTC] chriskl at familyhealth dot com dot au
This script fails with:

<b>Fatal error</b>:  Cannot redeclare test2() in <b>-</b> on line <b>4</b><br>

<?php

function test() {
	function test2() {
		echo "hi";
	}

	test2();
}

test();
test();
test();

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-02 04:14 UTC] hholzgra@php.net
php has no "nested function" feature like you'll find in PASCAL 
or in gcc if you enable the feature

what happens here is that test2 is registered on execution of
test in the global namespace, and when you call test a second time
it cannot register test2 again

(the engine shouldn't  accept nested functions at all i think)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 20:01:31 2024 UTC