Does the 'use' keyword trigger autoloading in PHP?

前端 未结 1 1978
死守一世寂寞
死守一世寂寞 2021-01-20 19:19

In the example below, at what point does the autoloader load the class file, if at all? For example, if $boolean_test === false does the Subpackage get loaded?<

1条回答
  •  时光说笑
    2021-01-20 19:58

    No use does not trigger autoloading. You can have an invalid use at the top of your file and PHP won't complain.

    Autoloading happens when you attempt to use the class.

    It's quite easy to test this: https://3v4l.org/OccF3

    0 讨论(0)
提交回复
热议问题