参考-这个符号在PHP中是什么意思? [英] Reference — What does this symbol mean in PHP?
问题描述
这是什么?
这是有关PHP语法的不时出现的问题的集合.这也是一个社区Wiki,因此邀请所有人参与维护此列表.
这是为什么?
过去很难找到有关运算符和其他语法标记的问题.¹
主要思想是链接到Stack Overflow上的现有问题,因此我们更容易引用它们,而不必复制PHP手册中的内容.
注意:自2013年1月起,堆栈溢出不支持特殊字符.只需用引号将搜索字词括起来,例如 [php] "==" vs "==="
我应该在这里做什么?
如果有人因为提出这样的问题而将您指向此处,请在下面找到特定的语法. PHP手册的链接页面以及链接的问题可能会回答您的问题.如果是这样,建议您增加答案.此列表不能替代其他人提供的帮助.
列表
如果您的特定令牌未在下面列出,则可以在解析器列表中找到令牌.
- 用&"号启动PHP函数意味着什么?
- 了解PHP& (与号,按位和)运算符
- PHP&"运算符
- &之间的差异和&&在PHP中
- &"是什么意思?是在PHP中表示的吗?
- &"是什么意思?在这种情况下是什么意思?
- &"是什么?符号在PHP中意味着什么?
- 此签名在PHP中是什么意思(&)?
- "&"运算符在PHP函数中工作?
- 什么是& & 2在PHP中是什么意思?
- 何时应使用按位运算符?
- 是否需要在对象前使用&"符号?(& $)
=&
参考
&=
按位运算符
&&
逻辑运算符
%
算术运算符
!!
逻辑运算符
@
错误控制运算符
?:
三元运算符
??
空联合运算符(自PHP 7起)
?string
?int
?array
?bool
?float
可返回值的类型声明(自PHP 7.1起)
::
范围解析运算符 >
- 两个冒号在PHP中是什么意思?
- PHP令牌名称T_PAAMAYIM_NEKUDOTAYIM是什么意思?
- ::(双冒号)和->有什么区别? (箭头)在PHP中?
- PHP中最新的静态绑定到底是什么?
- static :: staticFunctionName()
- 意外的T_PAAMAYIM_NEKUDOTAYIM,期望使用T_NS_Separator
\
命名空间
->
类和对象
- 什么是-" PHP运算符调用了,大声读出代码时怎么说?
- 在何处使用对象运算符-"在PHP中?
- ::(双冒号)和->有什么区别? (箭头)在PHP中?
- PHP语法$ var1-> $ var2是什么意思?
- ->"是什么意思?在PHP中是指/指代?
=>
数组
^
按位运算符
>>
按位运算符
<<
按位运算符
<<<
Heredoc或Nowdoc
=
分配运算符
==
比较运算符
===
比较运算符
!==
比较运算符
!=
比较运算符
<>
比较运算符
<=>
比较运算符(自PHP 7.0起)
|
按位运算符
||
逻辑运算符
~
按位运算符
+=
和-=
分配运算符
++
和--
递增/递减运算符
.=
分配运算符
.
字符串运算符
,
函数参数
,
变量声明
$$
变量
`
执行运算符
<?=
打开标签
[]
数组(PHP 5.4以来的短语法) )
<?
打开和关闭标签
...
参数解压缩(自PHP 5.6起)
**
幂运算(自PHP 5.6起)
#
单行外壳样式注释
:?
可为空的返回类型
++
增量运算符
--
减法运算符
Example Name Effect
---------------------------------------------------------------------
++$a Pre-increment Increments $a by one, then returns $a.
$a++ Post-increment Returns $a, then increments $a by one.
--$a Pre-decrement Decrements $a by one, then returns $a.
$a-- Post-decrement Returns $a, then decrements $a by one.
这些变量可以在变量之前或之后.
如果放在变量之前,先对变量进行递增/递减操作,然后返回结果.如果将变量放在变量之后,则首先返回该变量,然后执行递增/递减操作.
例如:
$apples = 10;
for ($i = 0; $i < 10; ++$i) {
echo 'I have ' . $apples-- . " apples. I just ate one.\n";
}
在使用++$i
的情况下,因为它更快. $i++
将具有相同的结果.
预增量要快一点,因为它确实增加了变量,然后返回"结果.后增量创建一个特殊变量,在其中复制第一个变量的值,只有在使用第一个变量后,才将其值替换为第二个.
但是,必须使用$apples--
,因为首先要显示当前的苹果数,然后然后要减去一个苹果.
您还可以在PHP中增加字母:
$i = "a";
while ($i < "c") {
echo $i++;
}
到达z
后,接着是aa
,依此类推.
请注意,字符变量可以递增但不能递减,即使如此,仅支持纯ASCII字符(a-z和A-Z).
堆栈溢出帖子:
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 the PHP Manual.
Note: Since January 2013, Stack Overflow does support special characters. Just surround the search terms by quotes, e.g. [php] "==" vs "==="
What should I do here?
If you have been pointed here by someone because you have asked such a question, please find the particular syntax below. The linked pages to the PHP manual along with the linked questions will likely answer your question then. If so, you are encouraged to upvote the answer. This list is not meant as a substitute to the help others provided.
The List
If your particular token is not listed below, you might find it in the List of Parser Tokens.
&
Bitwise Operators or References
- What does it mean to start a PHP function with an ampersand?
- Understanding PHP & (ampersand, bitwise and) operator
- PHP "&" operator
- Difference between & and && in PHP
- What does "&" mean here in PHP?
- What does "&" mean in this case?
- What does the "&" sign mean in PHP?
- What does this signature mean (&) in PHP?
- How does the "&" operator work in a PHP function?
- What does & in &2 mean in PHP?
- When should I use a bitwise operator?
- Is there ever a need to use ampersand in front of an object? (&$)
=&
References
- Reference assignment operator in PHP, =&
- What do the "=&" and "&=" operators in PHP mean?
- What do the '&=' and '=&' operators do?
- What does =& mean in PHP?
- 'AND' vs '&&' as operator
- Difference between & and && in PHP
- Is there any difference between "and" and "&&" operators in PHP?
- PHP - and / or keywords
- What does the percent sign mean in PHP?
- What is the PHP operator % and how do I use it in real-world examples?
- What is the use of the @ symbol in PHP?
- 'At' symbol before variable name in PHP: @$_POST
- PHP functions and @functions
- Should I use @ in my PHP code?
- What does @ mean in PHP?
- What are the PHP operators "?" and ":" called and what do they do?
- ?: operator (the 'Elvis operator') in PHP
- Where can I read about conditionals done with "?" and ":" (colon)?
- Using PHP 5.3 ?: operator
??
Null Coalesce Operator (since PHP 7)
?string
?int
?array
?bool
?float
Nullable return type declaration (since PHP 7.1)
:
Alternative syntax for control structures, Ternary Operator
- What do two colons mean in PHP?
- What's the meaning of the PHP token name T_PAAMAYIM_NEKUDOTAYIM?
- What's the difference between :: (double colon) and -> (arrow) in PHP?
- What exactly are late static bindings in PHP?
- static::staticFunctionName()
- Unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_NS_Separator
- What is the "->" PHP operator called and how do you say it when reading code out loud?
- Where do we use the object operator "->" in PHP?
- What's the difference between :: (double colon) and -> (arrow) in PHP?
- What does the PHP syntax $var1->$var2 mean?
- What does "->" mean/refer to in PHP?
=>
Arrays
- What does <<<END mean in PHP?
- PHP expression <<<EOB
- In PHP, what does "<<<" represent?
- Using <<<CON in PHP
- What's this kind of syntax in PHP?
- How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
- PHP != and == operators
- The 3 different equals
- Type-juggling and (strict) greater/lesser-than comparisons in PHP
- What does "===" mean?
- How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
- The 3 different equals
- Type-juggling and (strict) greater/lesser-than comparisons in PHP
- PHP != and == operators
- Is there a difference between !== and != in PHP?
- comparing, !== versus !=
- What is the difference between <> and !=
- PHP operator <>
- PHP's <> operator
- What is the difference between <> and !=
- Type-juggling and (strict) greater/lesser-than comparisons in PHP
<=>
Comparison Operators (since PHP 7.0)
- What is the difference between the | and || operators?
- What Does Using A Single Pipe '|' In A Function Argument Do?
- What is the difference between the | and || operators?
- PHP - and / or keywords
- What exactly does || mean?
- The behaviour of the or operator in PHP
+
Arithmetic Operators, Array Operators
+=
and -=
Assignment Operators
++
and --
Incrementing/Decrementing Operators
- Difference between period and comma when concatenating with echo versus return?
- What does a . (dot) do in PHP?
- What does $$ (dollar dollar or double dollar) mean in PHP?
- what is "$$" in PHP
- $function() and $$variable
<?=
Short Open Tags
[]
Arrays (short syntax since PHP 5.4)
- PHP arrays... What is/are the meaning(s) of an empty bracket?
- What is the meaning of []
- Php array_push() vs myArray[]
- What does [] mean when reading from a PHP array?
- Shorthand for arrays: literal
$var = []
empty array
...
Argument unpacking (since PHP 5.6)
**
Exponentiation (since PHP 5.6)
#
One-line shell-style comment
Incrementing / Decrementing Operators
++
increment operator
--
decrement operator
Example Name Effect
---------------------------------------------------------------------
++$a Pre-increment Increments $a by one, then returns $a.
$a++ Post-increment Returns $a, then increments $a by one.
--$a Pre-decrement Decrements $a by one, then returns $a.
$a-- Post-decrement Returns $a, then decrements $a by one.
These can go before or after the variable.
If put before the variable, the increment/decrement operation is done to the variable first then the result is returned. If put after the variable, the variable is first returned, then the increment/decrement operation is done.
For example:
$apples = 10;
for ($i = 0; $i < 10; ++$i) {
echo 'I have ' . $apples-- . " apples. I just ate one.\n";
}
In the case above ++$i
is used, since it is faster. $i++
would have the same results.
Pre-increment is a little bit faster because it really increments the variable and after that 'returns' the result. Post-increment creates a special variable, copies there the value of the first variable and only after the first variable is used, replaces its value with second's.
However, you must use $apples--
, since first, you want to display the current number of apples, and then you want to subtract one from it.
You can also increment letters in PHP:
$i = "a";
while ($i < "c") {
echo $i++;
}
Once z
is reached aa
is next, and so on.
Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported.
Stack Overflow Posts:
这篇关于参考-这个符号在PHP中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!