Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的php解释。。什么';箭头运算符之间的区别是什么?_Php - Fatal编程技术网

简单的php解释。。什么';箭头运算符之间的区别是什么?

简单的php解释。。什么';箭头运算符之间的区别是什么?,php,Php,我不熟悉这两个操作符之间的确切区别: -> 及 有很多不同之处吗?一个分配一个数组,另一个只是重命名或类似的操作?->是一个方法调用或属性调用操作符,=>是一个数组分配操作符 $foo = new Bar(); $foo->test(); // or even $foo->bar = 'baz'; // vs $foo = array( 'bar' => 'test' ); // And wrapping it all together!!! $foo

我不熟悉这两个操作符之间的确切区别:

->


有很多不同之处吗?一个分配一个数组,另一个只是重命名或类似的操作?

->
是一个方法调用或属性调用操作符,
=>
是一个数组分配操作符

$foo = new Bar();
$foo->test();
// or even
$foo->bar = 'baz';

// vs 

$foo = array(
    'bar' => 'test'
);

// And wrapping it all together!!!
$foo = new Bar();
$foo->baz = array( 'bar' => 'baz' );

->是用于访问类属性的this运算符,其中


=>用于数组

->
用于访问对象的属性,其中as
=>
用于在赋值期间将数组键与其值结合起来

$foo = new Bar();
$foo->test();
// or even
$foo->bar = 'baz';

// vs 

$foo = array(
    'bar' => 'test'
);

// And wrapping it all together!!!
$foo = new Bar();
$foo->baz = array( 'bar' => 'baz' );