Explore topic-wise MCQs in Php.

This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

Which one of the following statements is true for require() and require_once()?

A. They are functions
B. They are statements
C. They’ll not work if the () is not present
D. They can not be used to require files
Answer» C. They’ll not work if the () is not present
2.

Which one of the following statements is true for include_once() and require_once()?

A. Both are exactly the same
B. include_once is used for files where as require_once() is not
C. Both Handle the errors in the same way
D. Both do not handle the errors in the same way
Answer» E.
3.

If I already had a Debug class in the main namespace. What will be the output of the following PHP code?

A. error
B. hello from main
C. hello from main\Debug
D. debugView Answer
Answer» B. hello from main
4.

Which keyword can be used to fix the following PHP error?

A. fix
B. join
C. use
D. namespaceView Answer
Answer» D. namespaceView Answer
5.

Output: 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();View Answer
Answer» E.
6.

Which symbol is used to declare nested namespaces?

A. /
B. \
C. .
D. |
Answer» C. .
7.

Which one of the following is the correct way of declaring a namespace?

A. namespace my;
B. namespace my();
C. my namespace;
D. namespace(my);
Answer» B. namespace my();
8.

Which of the following can you place inside a namespace?

A. i)
B. ii)
C. iii)
D. i), ii) & iii)View Answer
Answer» E.
9.

Till which version of PHP, developers were forced to name their files in a global context?

A. PHP 4
B. PHP 5
C. PHP 5.2
D. PHP 5.3
Answer» E.
10.

A package is a set of related _________

A. Objects
B. Classes
C. Programs
D. Functions
Answer» C. Programs