What's the difference between :: (double colon) and -> (arrow) in PHP?

10/14 15:40
阅读数 0

问题:

There are two distinct ways to access methods in PHP, but what's the difference?在 PHP 中有两种不同的方法来访问方法,但有什么区别呢?

$response->setParameter('foo', 'bar');

and

sfConfig::set('foo', 'bar');

I'm assuming -> (dash with greater than sign or chevron) is used for functions for variables, and :: (double colons) is used for functions for classes.我假设-> (带有大于号或 V 形的破折号)用于变量函数,而:: :(双冒号)用于类函数。 Correct?正确的?

Is the => assignment operator only used to assign data within an array? =>赋值运算符是否仅用于在数组中分配数据? Is this in contrast to the = assignment operator which is used to instantiate or modify a variable?这与用于实例化或修改变量的=赋值运算符形成对比吗?


解决方案:

参考一: https://en.stackoom.com/question/DJZV
参考二: https://stackoom.com/question/DJZV
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部