|  |      1Cofyc      2012-08-13 14:09:47 +08:00 public function one() { // do stuff } | 
|  |      2Cofyc      2012-08-13 14:09:48 +08:00 public function one() { // do stuff } | 
|  |      3Cofyc      2012-08-13 14:11:27 +08:00 public function one() { // do stuff return $this; } public function two() { // do stuff return $this; } // ... 不知道按了什么按键,连发了两次不完整的。。。 | 
|      4cave OP @Cofyc 可是这样实现跟References有关系吗? 我以为会是形如: class test{ public $f; public function & one(){ …… } public function & two(){ …… } } | 
|  |      5Cofyc      2012-08-13 14:28:56 +08:00 php 里对象变量存储的就是对象的 reference 不需要 & | 
|  |      6Cofyc      2012-08-13 14:30:53 +08:00 jQuery 里写法也是这样的,比如: // ... ready: function( fn ) { // Attach the listeners jQuery.bindReady(); // Add the callback readyList.add( fn ); return this; }, // ... | 
|  |      7yesmeck      2012-08-13 14:32:10 +08:00 每个方法都 return $this; | 
|      8cave OP | 
|  |      9yesmeck      2012-08-13 15:38:01 +08:00 @cave 你这个代码是在手册下面的评论里看到的吧。你看那个评论时间,在以前 PHP 的对象不是引用传递的所以没办法直接 return $this; 来实现链式调用。 | 
|  |      11xcl3721      2012-08-28 10:32:26 +08:00 |