php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27333 Includes from __autoload() doesn't register global variables.
Submitted: 2004-02-20 11:48 UTC Modified: 2004-02-20 12:28 UTC
From: davojan at mail dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0b4 (beta4) OS: FreeBSD 4.7-RELEASE
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: davojan at mail dot ru
New email:
PHP Version: OS:

 

 [2004-02-20 11:48 UTC] davojan at mail dot ru
Description:
------------
If script links from __autoload(), global variables, defined in it, are not visible in the calling environment.

In the simple example below I executed 'autoload.php'.

Reproduce code:
---------------
file 'foo.php':
<?
	$GLOBAL_VAR = 'GLOBAL_VAR';
	class foo {}
?>

file 'autoload.php':
<?
	function __autoload ($name)
	{
		require_once 'foo.php';
	}
	$foo = new foo();
	echo $GLOBAL_VAR;
?>

Expected result:
----------------
GLOBAL_VAR

Actual result:
--------------
Notice: Undefined variable: GLOBAL_VAR in /usr/local/www/data-dist/ils/admin/test/autoload.php on line 7


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-20 12:28 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Your so called global variable is obviously local to the calling function (__autoload).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 31 07:00:01 2025 UTC