php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33239 scope of function/classes definition in inclusion
Submitted: 2005-06-03 22:08 UTC Modified: 2005-06-06 17:25 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pythonboy at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pythonboy at gmail dot com
New email:
PHP Version: OS:

 

 [2005-06-03 22:08 UTC] pythonboy at gmail dot com
Description:
------------
When a file contains function/class definition and this file is included inside another function/method the definition has global scope

Reproduce code:
---------------
Example

function wilma()
{
   //fred.php contains fred() function definition
   include('fred.php') ;
}

wilma() ;
//prints "yabba-yabba-doo"
echo fred() ;


Expected result:
----------------
As to the manual...
http://www.php.net/manual/en/function.include.php

Fatal error: Call to undefined function: fred()  

Actual result:
--------------
fred() is defined in global scope

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-06 17:25 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"All functions and classes defined in the included file have the global scope."
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Feb 26 19:00:01 2026 UTC