Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

php调用静态方法后再链式调用,是什么原理?

图片描述

with方法在model类没有被定义,我猜想是用下图实现的
图片描述

图片描述

看不懂这段实现,有没有大神讲解一下!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

__callStatic是一个魔术方法,在调用不存在的静态方法时,会将函数名和参数传入此方法调用。
链式调用的原理则是中间方法会返回一个对象,return $this;,或这段代码里的数据库查询对象。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...