I will show you all a question regarding argument passing to a function in php. In php 5.3.0 we can assign NULL by reference to any argument. Now let’s see the question of ZEND mock test. The bold options are the answers. You can give your opinion about the answers.
Question: Which of the following is incorrect?[choose 4]
a. function c(MyClass $a = new MyClass())
You can't create an object of a class in this way.
b. function d($a = null)
php 5.3.0 gives option to set argument as null.
c. function e(&$a = 30)
You can’t assign default value to a parameter by reference.
d. function a(&$a = array(10,20,30))
Arrays can not be assigned to an argument.
e. function b($a = (10 + 2))
you can not assign an expression to an argument In a function.
Question: Which of the following is incorrect?[choose 4]
a. function c(MyClass $a = new MyClass())
You can't create an object of a class in this way.
b. function d($a = null)
php 5.3.0 gives option to set argument as null.
c. function e(&$a = 30)
You can’t assign default value to a parameter by reference.
d. function a(&$a = array(10,20,30))
Arrays can not be assigned to an argument.
e. function b($a = (10 + 2))
you can not assign an expression to an argument In a function.


1 comment:
All the question is wrong , both 'd' and 'c' are correct , only 'e' and 'a' are not allowed
Post a Comment