ExamVeda
Login
Home
81
Which keyword can be used to fix the above error?
Discuss
Answer & Solution
Answer: Option C
Solution:
Use keyword allows you to alias other namespaces within the current namespace. Example – namespace main; use comgetinstanceutil; utilDebug::helloWorld();
82
Which one of the following statements is true for include_once() and require_once()?
Discuss
Answer & Solution
Answer: Option D
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.
83
Which one of the following statements is true for require() and require_once()?
Discuss
Answer & Solution
Answer: Option B
Solution:
require() and require_once() are actually statements, not functions. This means that you can omit the brackets when using them.
84
Which function was introduced to help automate the inclusion of class files?
Discuss
Answer & Solution
Answer: Option C
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.
85
How many times can you define _______ autoload in a process?
Discuss
Answer & Solution
Answer: Option A
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.
86
Which one of the following functions will you use to check that the class exists before you work with it?
Discuss
Answer & Solution
Answer: Option B
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.
87
Which one of the following will you use to check the class of an object?
Discuss
Answer & Solution
Answer: Option D
Solution:
This function accepts any object as an argument and returns its class name as a string.
88
PHP 4 did not support instanceof. Instead, which function did it provide?
Discuss
Answer & Solution
Answer: Option C
Solution:
As of PHP 5.3 is_a() no longer deprecated.
89
You use the get_class_methods() function to return the names of all the methods in the class. Which function will you use to print it on the screen?
Discuss
Answer & Solution
Answer: Option C
Solution:
The function get_class_methods returns an array therefore we cannot use echo.
90
If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function will you use?
Discuss
Answer & Solution
Answer: Option C
Solution:
There is another method which you can use – method_exists() for similar purpose.