|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-02-14 17:32 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 22:00:02 2025 UTC |
Description: ------------ The order in which php code (a class) is declared and referenced in the sourcefile causes a compile error if not properly considered. In PHP 4, declaring a class after referencing it posed no problem. In PHP 5 it generates a compile error. Reproduce code: --------------- <?php $myinst = new myClass(); echo $myinst->myvar; class myClass { public $myvar; function __construct() { $this->myvar = "initial value"; } } ?> Expected result: ---------------- "Initial value" should be printed to the output window/page/console. Actual result: -------------- <b>Fatal error</b>: Class 'myClass' not found in <b>C:\myClass.php</b> on line <b>2</b><br />