What are the PHP operators quot;?quot; and quot;:quot; called and what do they do?(PHP 运算符“?是什么?和“:打电话,他们做什么?)
问题描述
什么是 ?
和 :
PHP 中的操作符?
What are the ?
and :
operators in PHP?
例如:
(($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER)
推荐答案
这是条件运算符.
$x ? $y : $z
表示如果$x
为真,则使用$y
;否则使用$z
".
means "if $x
is true, then use $y
; otherwise use $z
".
它也有一个简短的形式.
It also has a short form.
$x ?: $z
表示如果$x
为真,则使用$x
;否则使用$z
".
means "if $x
is true, then use $x
; otherwise use $z
".
人们会告诉你 ?:
是三元运算符".这是错误的.?:
是 a 三元运算符,也就是说它有三个操作数.人们最终认为它的名字是三元运算符",因为它通常是给定语言唯一的三元运算符.
People will tell you that ?:
is "the ternary operator". This is wrong. ?:
is a ternary operator, which means that it has three operands. People wind up thinking its name is "the ternary operator" because it's often the only ternary operator a given language has.
这篇关于PHP 运算符“?"是什么?和“:"打电话,他们做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 运算符“?"是什么?和“:"打电话,他们做什么?


基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01