<?php
//常见if条件语句
$sex = 1;
if ($sex === 1) {
echo "男";
} else {
echo "女";
}
//简化if语句
if ($sex === 1) echo "男";
else echo "女";
// //三元运算符
$x = ($sex === 1 ? 男 : 女);
echo ($x);点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号