summaryrefslogtreecommitdiff
path: root/Zend/ZEND_CHANGES
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2002-09-04 15:03:41 +0000
committerStanislav Malyshev <stas@php.net>2002-09-04 15:03:41 +0000
commit36c60cea388ccba58f424f6f8b15b2a0b3d01620 (patch)
tree9aabaf0196919b3b175b1752e68f9be41aa0b861 /Zend/ZEND_CHANGES
parent20f85627f5d6e4acc5c0fa356b9fb483a3389d70 (diff)
downloadphp-git-36c60cea388ccba58f424f6f8b15b2a0b3d01620.tar.gz
Fix __call and add some docs
Diffstat (limited to 'Zend/ZEND_CHANGES')
-rw-r--r--Zend/ZEND_CHANGES52
1 files changed, 51 insertions, 1 deletions
diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES
index babd167f20..48e12b79ca 100644
--- a/Zend/ZEND_CHANGES
+++ b/Zend/ZEND_CHANGES
@@ -534,7 +534,57 @@ Changes in the Zend Engine 2.0
* __autoload(). TBD.
- * __call(), __get(), __set(). TBD.
+ * Method calls and property accesses can be overloaded by class
+ methods __call(), __get() and __set().
+ Examples:
+
+ <?php
+ class Setter {
+ var $n;
+ var $x = array("a"=>1,"b"=>2,"c"=>3);
+ function __get($nm) {
+ print "Getting [$nm]\n";
+ if(isset($this->x[$nm])) {
+ $r = $this->x[$nm];
+ print "Returning: $r\n";
+ return $r;
+ } else {
+ print "Nothing!\n";
+ }
+ }
+ function __set($nm, $val) {
+ print "Setting [$nm] to $val\n";
+ if(isset($this->x[$nm])) {
+ $this->x[$nm] = $val;
+ print "OK!\n";
+ } else {
+ print "Not OK!\n";
+ }
+ }
+ }
+
+ $foo = new Setter();
+ $foo->n = 1;
+ $foo->a = 100;
+ $foo->a++;
+ $foo->z++;
+ var_dump($foo);
+ ?>
+
+ <?php
+ class Caller {
+ var $x = array(1,2,3);
+ function __call($m, $a) {
+ print "Method $m called:\n";
+ var_dump($a);
+ return $this->x;
+ }
+ }
+
+ $foo = new Caller();
+ $a = $foo->test(1, "2", 3.4, true);
+ var_dump($a);
+ ?>
Changes in the Zend Engine 1.0