What Does This Mean in PHP -gt; or =gt;(这在 PHP 中是什么意思 -或 =)
问题描述
可能的重复:
我们使用对象运算符->"的地方在 php 中
参考 - 这个符号在 PHP 中是什么意思? >
我一直在 PHP 中看到这些,但我不知道它们的实际含义.->
有什么作用,=>
有什么作用.我不是在谈论运营商.他们是别的东西,但似乎没有人知道...
I see these in PHP all the time but I don't have a clue as to what they actually mean. What does ->
do and what does =>
do. And I'm not talking about the operators. They're something else, but nobody seems to know...
推荐答案
双箭头运算符,=>
,用作数组的访问机制.这意味着它左侧的内容将具有数组上下文中右侧内容的相应值.这可用于将任何可接受类型的值设置为数组的相应索引.索引可以是关联的(基于字符串的)或数字.
The double arrow operator, =>
, is used as an access mechanism for arrays. This means that what is on the left side of it will have a corresponding value of what is on the right side of it in array context. This can be used to set values of any acceptable type into a corresponding index of an array. The index can be associative (string based) or numeric.
$myArray = array(
0 => 'Big',
1 => 'Small',
2 => 'Up',
3 => 'Down'
);
对象运算符,->
,用于在对象范围内访问对象的方法和属性.意思是说运算符右边的是实例化为运算符左边变量的对象的成员.实例化是这里的关键术语.
The object operator, ->
, is used in object scope to access methods and properties of an object. It’s meaning is to say that what is on the right of the operator is a member of the object instantiated into the variable on the left side of the operator. Instantiated is the key term here.
// Create a new instance of MyObject into $obj
$obj = new MyObject();
// Set a property in the $obj object called thisProperty
$obj->thisProperty = 'Fred';
// Call a method of the $obj object named getProperty
$obj->getProperty();
这篇关于这在 PHP 中是什么意思 ->或 =>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:这在 PHP 中是什么意思 ->或 =>


- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01