Wednesday, July 29, 2009

pass by reference in php 5

let's see a zend mock test question for php 5 certification.

Question:

Consider the following script:


This code has changed behavior in PHP 5. Identify the output of this script as it would have been in PHP 4, as well as the new behavior in PHP 5.


Answer:

1. array('a', 'a', 'b')
2. array('a', 'b', 'c')
This will show in php 5.
3. array('c', 'b', 'a')
4. array('c', 'c', 'c')
I think this will be the result for php 4.
5. array('b', 'b', 'b')
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide

2 comments:

Georgi said...

I don`t know about PHP4, but PHP5 outputs:
array('c', 'c', 'c')

Anonymous said...

answer is the other way round