扫码关注官方订阅号
$str = new str(); //类似这种链式操作,如何实现? $str->str()->length();
业精于勤,荒于嬉;行成于思,毁于随。
Class MyClass { public function doWork() { echo "work done\n"; return $this; } public function doAnotherWork() { echo "another work done\n"; return $this; } } (new MyClass())->doWork()->doAnotherWork();
ThinkPHP的数据库操作就支持这种方式,你可以看看他的实现方法。
return $this;
https://segmentfault.com/a/1190000003069...
很简单,返回对象即可。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
ThinkPHP的数据库操作就支持这种方式,你可以看看他的实现方法。
https://segmentfault.com/a/1190000003069...
很简单,返回对象即可。