This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
在PHP中有两种不同的方法来访问方法,但有什么区别?
$response->setParameter('foo', 'bar');
Run Code Online (Sandbox Code Playgroud)
和
sfConfig::set('foo', 'bar');
Run Code Online (Sandbox Code Playgroud)
我假设->(用大于号或破坏号的破折号)用于变量的函数,而::(双冒号)用于类的函数.正确?
是=>赋值运算符仅用于一个阵列中分配的数据?这与=用于实例化或修改变量的赋值运算符形成对比吗?
我想更好地理解OOP中的基本概念.面向对象编程中的静态和动态变量和方法是什么?例如,使用$ this与双冒号(::)之间的区别是什么?
$this->method_from_an_extended_class().