Why does
<?php
namespace Foo;
echo Bar::class;
output Foo\\Bar
without any errors, warnings, or notices? I would have expected some sort of "Class does not exist" message.
From PHP's document
The class name resolution using ::class is a compile time transformation. That means at the time the class name string is created no autoloading has happened yet. As a consequence, class names are expanded even if the class does not exist. No error is issued in that case.
So, it is documented and an expected behavior
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.