Tuesday, July 7, 2009

Arguments of a function

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.




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

1 comment:

Seif said...

All the question is wrong , both 'd' and 'c' are correct , only 'e' and 'a' are not allowed