|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-02-25 05:23 UTC] gopalv82 at yahoo dot com
[2006-03-14 01:30 UTC] gopalv82 at yahoo dot com
[2006-03-28 00:39 UTC] gopalv82 at yahoo dot com
[2006-05-13 09:41 UTC] gopalv82 at yahoo dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 22:00:01 2025 UTC |
Description: ------------ APC 3.0.8, Apache 2 When require()ing a class in a seperate file that extends a prior defined class, APC caches the require()d file with all class variables from the parent. Dynamically defining the parent with different variable values will not change the variable values in the inheriting class. This also applies when conditionally require()ing the parent class from different files. But functions are inherited fine. A workaround is to define the variable values in an inherited function, e.g. a constructor. Reproduce code: --------------- File "apc_start.php" <?php if (isset($_GET['new_engine'])) { class engine { public $engine_name = 'New engine.'; function print_engine_function() { echo "New engine."; } } } else { class engine { public $engine_name = 'Old engine.'; function print_engine_function() { echo "Old engine."; } } } require('apc_include.inc.php'); $o = new user_script(); $o->print_engine_variable(); $o->print_engine_function(); echo "<p /><a href='".$_SERVER['PHP_SELF']."?new_engine'>New engine</a>"; echo "<br /><a href='".$_SERVER['PHP_SELF']."'>Old engine</a>"; ?> File "apc_include.inc.php" <?php class user_script extends engine { function print_engine_variable() { echo $this->engine_name; } } ?> Expected result: ---------------- Old engine.Old engine. New engine.New engine. Actual result: -------------- Old engine.Old engine. New engine.Old engine.