对象链:
1)jquery中对象链
$(’.dog’).find(‘img’).attr({‘src’:‘cai.png’}).parent().css(‘background’,’#aaf’).css(‘transform’,‘rotate(’+s+‘deg)’);
2)php对象链
$dog->find()->attr()->parent()->css();
对象调用结构:
对象->成员
对象链
<?php
// 类
class Person{
// 方法
public function find(){
echo "<p>this is find action</p>";
return $this;
}
public function attr(){
echo "<p>this is attr action</p>";
return $this;
}
public function parent(){
echo "<p>this is parent action</p>";
return $this;
}
public function css(){
echo "<p>this is css action</p>";
return $this;
}
public $name='<p>小马过河</p>';
}
$obj=new Person();
echo $obj->attr()->css()->attr()->find()->parent()->css()->name;
?>
**
this is attr action
this is css action
this is attr action
this is find action
this is parent action
this is css action
小马过河