Answer the question
In order to leave comments, you need to log in
Is it necessary to include a file containing a namespace?
Created two classes admin.php and index.php . In the first I described the namespace, in the second I use it.
If I call require_once('admin.php'); then the namespace works without the use keyword . If I do not call, then nothing works at all.
And in the examples of the tutorial it is written as "connect via use NAMESPACE and you do not need to include a file containing a description of the namespace."
So is it necessary to include a namespace description file?
Answer the question
In order to leave comments, you need to log in
use is the syntactic sugar at the level of this particular file. Only to write new Admin instead of new Mycoolapp\model\Admin. Not related to include/require
include or require are required. Another thing is that usually they are not written to load classes explicitly, but are called through Autoloading
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question