相关疑难解决方法(0)

Reference — What does this symbol mean in PHP?

What is this?

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.

Why is this?

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 arguments symbols operators

4314
推荐指数
21
解决办法
63万
查看次数

PHP中的"=>"是什么意思?

=>运算符在以下代码中的含义是什么?

foreach ($user_list as $user => $pass)
Run Code Online (Sandbox Code Playgroud)

该代码是PHP.net上的评论.用户没有指定的值$user_list,$user或$通过.我通常认为这=>意味着等于或大于.

但是,我不确定它的用途,因为它没有分配.我把代码读成了

  1. 处理整数中的用户列表
  2. 使得每个用户的值等于或大于密码

以上对我没有意义.

php

93
推荐指数
5
解决办法
10万
查看次数

PHP 等于 foreach 循环中的箭头运算符

可能的重复:
foreach($ex as $k=>$v) 中的 $k => $v 是什么意思?

我试图理解这意味着什么:

foreach($this->domains as $domain=>$users) {  

// some code...

}
Run Code Online (Sandbox Code Playgroud)

我知道$this->domains是一个foreach将索引的数组。但是是什么as $domain=>$users意思呢?我只见过=>在数组中使用的运算符来设置 (key, value) 对。该类有一个名为 的成员$domain,但我认为它将作为$this->domain.

php arrays foreach

4
推荐指数
1
解决办法
9538
查看次数

如何在PHP中使用箭头功能?

我了解PHP 7.4中的箭头功能。我尝试像这样使用它们

<?php
$num = 1;
$arrowfunction = () => {
   return $num + 1;
}
echo $arrowfunction();
Run Code Online (Sandbox Code Playgroud)

因为我=>在拉取请求中看到了运算符。就像JavaScript。

我希望输出为“ 2”,但这没有用!我有

解析错误:语法错误,第3行/test.php中出现意外的')'

php arrow-functions php-7.4

4
推荐指数
2
解决办法
664
查看次数