Home
Sign Up
Sign In
V2EX
›
PHP
$this->values[$id]($this),这种写法是什么意思呢?
ben548
·
Dec 28, 2015
· 3155 views
This topic created in 3962 days ago, the information mentioned may be changed or developed.
在看 php 的依赖注入框架 pimple 的源码时,看到这样的代码,感觉很奇怪,这种写法是什么意思呢?对了,$this->values 是一个数组
this-
values
写法
pimple
2 replies
•
2015-12-28 18:35:18 +08:00
cxbig
Dec 28, 2015
1
数组里都是 fn , key 可以匹配就直接调用。
这么写太短,除非提前验证$id 有对应的 fn 。
个人不推荐这种写法。在类里用标准的反射 method 调用比较好。
ben548
OP
Dec 28, 2015
2
@
cxbig
明白了,谢谢
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
4989 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 28ms ·
UTC 05:57
·
PVG 13:57
·
LAX 21:57
·
JFK 00:57
♥ Do have faith in what you're doing.
❯