cvs: phpweb / zend-engine-2.php
| From: | Gabor Hojtsy | Date: | Tue, 06 Apr 2004 13:06:20 +0000 |
| Subject: | cvs: phpweb / zend-engine-2.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-24189@lists.php.net to get a copy of this message | ||
goba Tue Apr 6 09:06:20 2004 EDT
Modified files:
/phpweb zend-engine-2.php
Log:
Apply patch from Friedhelm, since noone objected against it. Reworded the clone part a bit to be
more precise (I hope so :)
http://cvs.php.net/diff.php/phpweb/zend-engine-2.php?r1=1.24&r2=1.25&ty=u
Index: phpweb/zend-engine-2.php
diff -u phpweb/zend-engine-2.php:1.24 phpweb/zend-engine-2.php:1.25
--- phpweb/zend-engine-2.php:1.24 Fri Mar 19 02:58:03 2004
+++ phpweb/zend-engine-2.php Tue Apr 6 09:06:19 2004
@@ -1,5 +1,5 @@
<?php
-// $Id: zend-engine-2.php,v 1.24 2004/03/19 07:58:03 derick Exp $
+// $Id: zend-engine-2.php,v 1.25 2004/04/06 13:06:19 goba Exp $
$_SERVER['BASE_PAGE'] = 'zend-engine-2.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
site_header("Changes in PHP 5/Zend Engine 2.0");
@@ -267,10 +267,12 @@
of this other object so that the replica has its own separate copy.
</p>
<p>
- An object copy is created by calling the object's <code>__clone()</code> method:
+ An object copy is created by using the clone keyword (which calls the object's
+ <code>__clone()</code> method if possible). An object's
<code>__clone()</code>
+ method cannot be called directly.
</p>
<?php highlight_php('<?php
-$copy_of_object = $object->__clone();
+$copy_of_object = clone $object;
?>'); ?>
<p>
When the developer asks to create a new copy of an object, PHP 5 will
@@ -292,7 +294,6 @@
}
function __clone() {
- $this->name = $that->name;
$this->address = "New York";
$this->id = self::$id++;
}
@@ -305,11 +306,11 @@
print $obj->id . "\n";
-$obj = $obj->__clone();
+$obj_cloned = clone $obj;
-print $obj->id . "\n";
-print $obj->name . "\n";
-print $obj->address . "\n";
+print $obj_cloned->id . "\n";
+print $obj_cloned->name . "\n";
+print $obj_cloned->address . "\n";
?>');
?>
@@ -693,7 +694,7 @@
<h3>Example: __call()</h3>
<?php highlight_php('<?php
class Caller {
- var $x = array(1, 2, 3);
+ private $x = array(1, 2, 3);
function __call($m, $a) {
print "Method $m called:\n";
@@ -715,8 +716,8 @@
<h3>Example</h3>
<?php highlight_php('<?php
class Foo {
- var $x = 1;
- var $y = 2;
+ public $x = 1;
+ public $y = 2;
}
$obj = new Foo;
@@ -750,7 +751,7 @@
function rewind() {
$this->num = 0;
}
- function hasMore() {
+ function valid() {
return $this->num < $this->obj->max;
}
function key() {
@@ -832,9 +833,7 @@
}
}
-$obj = Foo;
-
-$str = (string) $obj; // call __toString()
+$obj = new Foo;
echo $obj; // call __toString()
?>'); ?>