Closed
Description
Description
The following code:
- Clear PHP Opcache
- Add files:
$ cat test.php
<?php
include( 'test-class1.php' );
include( 'test-class2.php' );
$ cat test-class1.php
<?php
class test_class {
public static $a = true;
}
$ cat test-class2.php
<?php
var_dump( test_class::$a );
class test_class {
public static $a = true;
}
- Issue a web request to test.php
- Remove the include -> "include( 'test-class1.php' )" from test.php
- Issue a second web request to test.php again
Resulted in this output:
First Request: Fatal error: Cannot declare class test_class, because the name is already in use in test-class2.php on line 5
Second Request: Fatal error: Uncaught Error: Class 'test_class' not found in test-class2.php:3
But I expected this output instead:
First Request: Fatal error: Cannot declare class test_class, because the name is already in use in test-class2.php on line 5
Second request: bool(true)
PHP Version
PHP 8.0
Operating System
Linux