Eclipse can not start after installed WTP
July 4th, 2009How to change file limit in Fedora Linux
July 4th, 2009ulimit command
July 4th, 200915 days to Fedora 11, still buggy
May 12th, 2009Fedora 11 in 16 days
May 10th, 2009Zend Framework 1.8 alpha
April 11th, 2009Zend Framework now approching version 1.8. Yesterday, it put the 1.8 alpha available for download. Also, the reference guide document has been updated including the feature of version 1.8.
It added 4 new components: Zend_Application, Zend_CodeGenerator, Zend_Tool_Framework, Zend_Tool_Project. Also, It supports more service like Zend_Service_Twitter and may be more.(I am not sure, because I have not checked what services included in previous versions).
Zend_CodeGenerator, Zend_Tool_Framework, Zend_Tool_Project looks like make up a tool chain to support Zend_Tool_Project, which looks like a command line tool can create the Zend Frame project sketch. In 1.8 alpha, it is hardly functional. What I can find out is just a zf.sh included in the bin folder, which you run
zf.sh create project ~/workspace/test
will create a default site struct in the given folder. However, the code generated has syntax error. (doule <?php), also, I can not figure out how to create projects using modules.
Most interesting part is the Zend_Application. It abstracts and wrap the common bootstrap procedures, so you don’t have to code the almost the same bootstrap file for each project.
I am doing a test project using Zend_Application bootstraping. Check out at:
http://code.google.com/p/yaz/source/browse/#svn/trunk
PHP object assign alway by reference
April 4th, 2009Different from what we discuss before about regular variable type, object assignment always by reference:
class A {
public $a = 'a';
}
$a = new A();
$b = clone $a;
$c = $a;
$b->a = 'b';
echo $a->a, "\n";
$c->a = 'c';
echo $a->a, "\n";
Output:
a c
We use clone to make a copy of object. Please note that default clone operation is shallow copy. You have to overload the __clone method if you want deep copy of the object.
PHP return by reference
April 4th, 2009We can ask a function return by reference by adding a & before function declare. See example:
function & pass(& $a) {
return $a;
}
function duplicate(& $a) {
return $a;
}
$a = array('a'=>'a');
$b = duplicate($a);
$c = & pass($a);
$b['a'] = 'b';
echo $a['a'], "\n";
$c['a'] = 'c';
echo $a['a'], "\n";
output is:
a c
You will see, the trick here is: don’t forget to put an ‘&’ before the function of assign operation. Otherwise, the assign operation will make a copy of the returned reference.
PHP assign by reference
April 4th, 2009See codes below:
$a = array('a'=>'a');
$b = $a; // $b is a copy of $a
$c = & $a; // $c is a reference of $a
$b['a'] = 'b'; // $a not changed
echo $a['a'], "\n";
$c['a'] = 'c'; // $a changed
echo $a['a'], "\n";
The output is:
a c
Also, we know that when we use [] to get a data from an array, this return the reference to the internal data. So it we pass in a reference of data to array, and then we get the data from the array. This operation will change the original data.
See below:
$a = array('a'=>'a');
$b = array();
$b[] = $a;
$b[] = & $a;
$b[0]['a'] = 'b';
echo $a['a'],"\n";
$b[1]['a'] = 'c';
echo $a['a'], "\n";
output is:
a c
