What are the two question marks in php?
In this issue, the editor will bring you about what the two question marks in php refer to. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
The two question marks in php are a new NULL merge operator introduced by php7, which is used in ways such as "$username = $_ GET ['user']?' nobody';".
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.
What do two question marks mean in php?
Actually, two question marks? Is a new expression from php7:
An additional NULL merge operator has been added in the PHP7+ version. An example is as follows:
Example
Php7 used to use ternary expressions frequently:
Ternary operator:
Another conditional operator is the "?:" (or ternary) operator.
Grammatical format
(expr1)? (expr2): (expr3)
The value is expr2 when expr1 is evaluated as TRUE and expr3 when expr1 is evaluated as FALSE.
As of PHP 5.3, the middle part of the ternary operator can be omitted. The expression expr1?: expr3 returns expr1 when expr1 evaluates to TRUE, otherwise it returns expr3.
This is what the two question marks in the php shared by the editor refer to. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.