"."/> ".">
Home > Article > Backend Development > Is it not possible to use if in php?
PHP can use if; the if structure is one of the most important features of many languages, including PHP, which allows code fragments to be executed according to conditions; the syntax for using if in PHP is such as "1da50fe23526f589cd5b87b96bf6172a".
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
Is php not available? if?
PHP can use if.
The if structure is one of the most important features of many languages, including PHP, which allows the execution of code fragments based on conditions. PHP's if construct is similar to the C language:
<?php if (expr) statement ?>
As defined in the Expressions chapter, expr evaluates to a Boolean. If the value of expr is true, PHP will execute the statement, if the value is false - the statement will be ignored. See the Converting to Boolean section for more information on which values are considered false.
If $a is greater than $b, the following example will show that a is bigger than b:
<?php if ($a > $b) echo "a is bigger than b"; ?>
It is often necessary to execute more than one statement according to conditions. Of course, there is no need to add Previous if clause. These statements can be placed into statement groups. For example, if $a is greater than $b, the following code will display that a is bigger than b and assign the value of $a to $b:
<?php if ($a > $b) { echo "a is bigger than b"; $b = $a; } ?>
if statements can be nested within other if statements indefinitely, This provides sufficient flexibility for conditional execution of different parts of the program.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Is it not possible to use if in php?. For more information, please follow other related articles on the PHP Chinese website!