php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #13568 PHP3 semantics have been retained for nested functions
Submitted: 2001-10-05 14:56 UTC Modified: 2002-11-28 14:44 UTC
From: alvarez at st-oneline dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.10 OS: *
Private report: No CVE-ID: None
 [2001-10-05 14:56 UTC] alvarez at st-oneline dot net
container ();

a script to reproduce the error quickly.

function container () {

  function nested_php3 () {
     echo "this will be output";
  }

  nested_php3 ();

  nested_php4 ();
 
  function nested_php4 () {
      echo "this won't be output";
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 14:01 UTC] yohgaki@php.net
Parhaps,  ZE2  should depreciate this syntax.

I really want BNF for PHP.

 [2002-09-09 08:14 UTC] hholzgra@php.net
the new semantics that allows calling functions prior to their definition only works for functions defined in a global scope

as soon as a function definition is within a conditional
block or nested within another function the new function
cannot be created at parse time as it is not known yet
wether the condition will be met or the surrounding 
function ever called, so these functions are created at
runtime instead when execution reaches this part of the code

so it is rather obvious that you can't call such a function ahead of it's definition

well, maybe not *that* obvious, reclassified as documentation problem ...
 [2002-11-28 14:44 UTC] pollita@php.net
Documentation at http://www.php.net/manual/en/functions.php updted.  "Why conditional functions don't immediately exist."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 07:01:29 2025 UTC