Print a string if $a is less than five:
<?php
$a = 4;
if($a < 5) {
echo "Less than five";
}
?>
Try it Yourself »
The if
keyword is used to create an if conditional. The elseif
and else
keywords can be used to specify code that runs when the condition is not met.
The elseif
keyword
The else
keyword
Read more about conditionals in our PHP Conditionals Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!