#31562 [Fbk->Opn]: __autoload() problem with static variables

From: Date: Sun, 06 Mar 2005 21:59:10 +0000
Subject: #31562 [Fbk->Opn]: __autoload() problem with static variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-74985@lists.php.net to get a copy of this message
 ID:               31562
 User updated by:  aalbre99 at student dot hia dot no
 Reported By:      aalbre99 at student dot hia dot no
-Status:           Feedback
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows XP
 PHP Version:      5.0.3
 New Comment:

Sorry.

Replaced all my PHP files with the files in
http://snaps.php.net/win32/php5-win32-latest.zip.

Still same error...

(I'am using the built-in IIS in Windows XP SP2)


-------------------------
 Output from 'test.php':
-------------------------

Fatal error: Class 'TestClass' not found in
C:\_ECLIPSE_\test\other\Other.php on line 5


Previous Comments:
------------------------------------------------------------------------

[2005-02-28 21:02:08] sniper@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-01-15 13:51:02] aalbre99 at student dot hia dot no

I have created an application which reproduces the error. And now I see
that the error is caused by something other than I thought in the
beginning...

Put the following files in the following folder structure, and load
'test.php'...

/test.php
/class_files/ErrorHandler.php
/class_files/TestClass.php
/other/Other.php

#test.php#
<?php
function __autoload($className) {	
	require_once("class_files/" . $className . ".php");
}

//Uncoment this line to bypas the bug...
//require_once("class_files/TestClass.php");

class Test
{	
	public function Test()
	{		
		$errorHandler = new ErrorHandler();
		
		require_once("Other/Other.php");		
		$other = new Other();			
	}	
}

$test = new Test();
?>

#TestClass.php#
<?php
class TestClass
{
	public static $staticVar;
	
	public function TestClass()
	{
		//Set ErrorHandler
		set_error_handler(array($this, 'handlePhpError'));		
	}
}
?>

#ErrorHandler.php#
<?php
class ErrorHandler
{
	public function ErrorHandler()
	{
		error_reporting(E_ALL);
		set_error_handler(array($this, 'handlePhpError'));		
	}
	
	public function handlePhpError($type, $msg, $file, $line)	
	{
		$myVar = TestClass::$staticVar;	
		echo "Error!";			
	}
}
?>

#Other.php#
<?php
class Other 
{
	//Produces warning!
	var $temp = 'temp';
	
	public function Other()	{}	
}
?>

------------------------------------------------------------------------

[2005-01-15 13:06:37] aalbre99 at student dot hia dot no

YES. I managed to reproduce the error in my PHP application!
(One line was changed...)

I will now try to make a test application I can post here which
generates the same error... Stay tuned...

------------------------------------------------------------------------

[2005-01-15 12:56:52] aalbre99 at student dot hia dot no

This is the strangest thing...

Today my PHP application works fine, but I am sure that it didn't work
yesterday. No changes in the code, only a reboot of my computer since
yesterday....

------------------------------------------------------------------------

[2005-01-15 12:40:37] aalbre99 at student dot hia dot no

Thought it was a general bug, but it's not...

If you replace 
"$myVar = MyClass::$classVar;"
with
"$myVar = ErrorFetcher::$classVar;"
you will se the error...

Is this a bug, or is it me how have chosen a bad name for my class....?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/31562

-- 
Edit this bug report at http://bugs.php.net/?id=31562&edit=1


Thread (12 messages)

« previous php.bugs (#74985) next »