I have an issue after upgrade from PHP 7.3 to 8.1.1 There is lot to be done of course, but this is kind of weird. This example is not working for me with error Fatal error:
Uncaught Error: Class "TestC" not found in C:\xampp81\htdocs\helpdesk811\test81\index.php:2 Stack trace: #0 {main} thrown in C:\xampp81\htdocs\helpdesk811\test81\index.php on line 2
<?php
$a = new TestC;
echo $a->a;
class TestC
{
public $a = "a_value";
public $b;
public function __toString()
{
return "string";
}
}
If I define class and create instance later, it works, but I was not able to find any documentation for this behavior.It's the same with static method (public static function foo(){echo "bar";}).
I tried 3v4l.org sandbox and it works in versions >5.0 && <8.0