|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-15 09:28 UTC] damien dot mirand at laposte dot net
Description:
------------
When using defined constants to ensure each include class
file is only included once, it produces an error
complaining that the specified class has already been
defined, despite the defined constant normally prevents
it.
Reproduce code:
---------------
--test_bug_1.php--
<?php
include( 'test_bug_1.inc' ) ;
include( 'test_bug_1.inc' ) ;
?>
--test_bug_1.inc--
<?php
if( !defined('FOOFOO') )
{
define('FOOFOO',TRUE) ;
class Foofoo {}
}
?>
Expected result:
----------------
Works with no error.
Actual result:
--------------
Fatal error: Cannot redeclare class
in /srv/www/htdocs/op4demo/html/test_bug_1.php on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 31 04:00:01 2025 UTC |
Same with CVS. v. 3.0.10 & 3.0.9 are affected. v. 3.0.8 and older are not. In fact it also occurs with : --test_bug_1.php-- <?php include( 'test_bug_1.inc' ) ; include( 'test_bug_1.inc' ) ; ?> --test_bug_1.inc-- <?php if( !class_exists('Foofoo') ) { class Foofoo {} } ?> It seems that a class include file cannot be included more than once, even if there's "checks" on it. By checks I mean defined constants, or even the 'class_exists' method.