<?php
class String{
private $str;
public function __construct($str){
$this->str=$str;
}
public function cut($length){
$this->str=substr($this->str, 0,$length);
return $this;
}
public function upCase(){
$this->str=strtoupper($this->str);
return $this;
}
public function output(){
var_dump($this->str);
}
}
$str=new String("the quick fox jump over the brown dog.");
$str->cut(15)->upCase()->output();
php链式操作
于 2023-04-03 11:29:37 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)