【问题标题】:What does => mean in php? [duplicate]=> 在 php 中是什么意思? [复制]
【发布时间】:2011-02-02 07:38:20
【问题描述】:

可能重复:
What does “=>” mean in PHP?

我正在学习数组,但不确定 => 的含义或作用。

【问题讨论】:

标签: php


【解决方案1】:

将值分配给命名键。

http://www.php.net/manual/en/language.operators.assignment.php

$example = array('color' => 'blue');
echo $example['color']; //prints blue

【讨论】:

    【解决方案2】:

    我相信这只是编写数组文字的语法,其行为类似于地图/字典。

    $mydict = array('hello' => 'world');

    上面是一个有一个元素的数组。但是,如果使用整数索引对该元素进行索引,则使用键 'hello':

    echo $mydict['hello']

    【讨论】:

      猜你喜欢
      • 2012-11-27
      • 2011-05-04
      • 2011-05-06
      • 2020-10-27
      • 2015-07-15
      • 2018-07-17
      • 2012-08-13
      • 2011-05-31
      • 2011-05-29
      相关资源
      最近更新 更多