在PHP中:(双冒号)和->(箭头)有什么区别?在PHP中访问方法有两种不同的方法,但是有什么不同呢?$response->setParameter('foo', 'bar');和sfConfig::set('foo', 'bar');我假设->(大于符号或雪佛龙的破折号)用于变量的函数,以及::(双冒号)用于类的函数。对,是这样?是=>赋值运算符只用于分配数组中的数据?这与=赋值操作符用于实例化或修改变量?
3 回答
达令说
TA贡献1821条经验 获得超6个赞
::
class Math {
public static function sin($angle) {
return ...;
}}$result = Math::sin(123);::
class Rectangle {
protected $x, $y;
public function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}}class Square extends Rectangle {
public function __construct($x) {
parent::__construct($x, $x);
}}->
class Hello {
public function say() {
echo 'hello!';
}}$h = new Hello();$h->say();
婷婷同学_
TA贡献1844条经验 获得超8个赞
class Test {
public $name;
public function __construct() {
$this->name = 'Mrinmoy Ghoshal';
}
public static function doWrite($name) {
print 'Hello '.$name;
}
public function write() {
print $this->name;
}}Test::doWrite('Mrinmoy'); // Output: Hello Mrinmoy.
write
- 3 回答
- 0 关注
- 1213 浏览
添加回答
举报
0/150
提交
取消
