|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-23 08:51 UTC] lufei@php.net
-Status: Open
+Status: Verified
[2021-07-23 08:51 UTC] lufei@php.net
[2021-07-23 09:30 UTC] nikic@php.net
-Status: Verified
+Status: Duplicate
[2021-07-23 09:30 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 04:00:01 2025 UTC |
Description: ------------ PHP 7 can run these scripts correctly. PHP 8 reports error if the class has a `__toString` method. Test script: --------------- a.php: <?php require 'b.php'; class C { // with this __toString method, 'b.php' can not find clas C public function __toString() { return ''; } } function test() { return new C(); } ?> b.php: <?php var_dump(test()); ?> Expected result: ---------------- Script can run without error. Actual result: -------------- PHP Fatal error: Uncaught Error: Class "C" not found in /home/test/a.php:12 Stack trace: #0 /home/test/b.php(2): test() #1 /home/test/a.php(2): require('/home/test/b.ph...') #2 {main} thrown in /home/test/a.php on line 12