Output: [code] namespace main; com\getinstance\util\Debug::helloWorld() PHP Fatal error: Class 'main\com\getinstance\util\Debug'

Mỹ Duyên

New member
Output:
Code:
    namespace main;
    com\getinstance\util\Debug::helloWorld()
PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...
Using which one of the following PHP lines will the error be removed?
A. \\com\getinstance\util\Debug::helloWorld();
B. getinstance\util\Debug::helloWorld();
C. main.com\getinstance\util\Debug::helloWorld();
D. \com\getinstance\util\Debug::helloWorld();
 
Answer: d
Explanation: PHP is looking below the namespace main for com\getinstance\util and not finding it. That’s because we are using a relative namespace here. Just as you can make absolute URLs and filepaths by starting off with a separator so you can with namespaces.
 

Tìm kiếm

Back
Top