Object Oriented Concept - Study Mode

[#86] Which one of the following statements is true for include_once() and require_once()?
Correct Answer

(D) Both do not handle the errors in the same way

Explanation

Solution: The only difference between the include() and require() statements lies in their handling of errors. A file invoked using require() will bring down your entire process when you meet an error. The same error encountered via a call to include() will merely generate a warning and end execution of the included file.

[#87] Which one of the following statements is true for require() and require_once()?
Correct Answer

(B) They are statements

Explanation

Solution: require() and require_once() are actually statements, not functions. This means that you can omit the brackets when using them.

[#88] Which function was introduced to help automate the inclusion of class files?
Correct Answer

(C) __autoload()

Explanation

Solution: When the PHP engine encounters an attempt to instantiate an unknown class, it invokes the __autoload() function, passing it the class name as a string. It is up to the implementer to define a strategy for locating and including the missing class file.

[#89] How many times can you define _______ autoload in a process?
Correct Answer

(A) once

Explanation

Solution: __autoload is a powerful tool, but it does have some limitations. In particular, you can only define it once in a process. If you need to change your autoload function dynamically you should look at the spl_autoload_register function, which supports that functionality.

[#90] Which one of the following functions will you use to check that the class exists before you work with it?
Correct Answer

(B) class_exists()

Explanation

Solution: The class_exists() function accepts a string representing the class to check for and returns a Boolean true value if the class exists and false otherwise.