只是想让一个简单的if ... else语句起作用。最初,我们得到了:
<?php
$IntVariable = 75;
($IntVariable > 100) ? $Result = '$IntVariable is
greater than 100'
: $Result = '$IntVariable is less than or equal
to 100';
echo "<p>$Result</p>";
?>
需要将其转换为if ... else语句。到目前为止,我写过:
<?php
$IntVariable = 75;
if ($IntVariable > 100) {
$Result = '$IntVariable is greater than 100';
}
else {
$Result = '$IntVariable is less than or equal to 100';
}
else {
echo "<p>$Result</p>";
}
?>
我是PHP的新手,所以我可能会遗漏一些非常简单的东西......
答案 0 :(得分:1)
为什么else
再次echo $result
如果您有许多条件,可以使用else if
..否则请else
<?php
$IntVariable = 75;
if ($IntVariable > 100) {
$Result = '$IntVariable is greater than 100';
}
else {
$Result = '$IntVariable is less than or equal to 100';
}
echo "<p>$Result</p>";
?>