Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the two question marks in php?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report