|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-02-03 21:38 UTC] ejrx7753 at gmail dot com
Description: ------------ I'm able to enter any random string of characters and add "::class" and it will work fine without error. PHP Documentation clearly states that this ::class feature "allows for fully qualified class name resolution". It should be a fatal error just as with new C(). Quote: "The special ::class constant are available as of PHP 5.5.0, and allows for fully qualified class name resolution at compile, this is useful for namespaced classes:" (http://php.net/manual/en/language.oop5.constants.php) Test script: --------------- <?php error_reporting(E_ALL); ini_set('display_errors', '1'); var_dump(C::class); var_dump(\D::class); Expected result: ---------------- Expected a fatal error Actual result: -------------- string(1) "C" string(1) "D" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 12:00:01 2025 UTC |
It expands to what the fully qualified class name *would be*. It will not trigger an autoload. Consider instead this snippet: <?php namespace Foo { var_dump(C::class); var_dump(\D::class); } ?> Which prints: string(5) "Foo\C" string(1) "D"