<?php
class Test{
protected $a = 100;
protected $tmp = "";
function a($str){
$this->tmp .= $str;
return $this;
}
function __call($method,$args){
if($method == "t"){
$this->tmp = implode(',',$args);
}
return $this;
}
function b($str){
$this->tmp .= $str;
return $this;
}
function getJoinStr(){
return $this->tmp;
}
}
$test = new Test();
$str= $test->t('今年是')->a('年')->b('python')->getJoinStr();
echo $str;
php中__call的使用方法
最新推荐文章于 2023-09-23 21:56:34 发布