PHP Syntax Statements Conditional if


- Info:

- if statement executes specified code if specified condition is true.

- PHP supports dual syntax for if statement where second one is being depricated.

- If code contains only single statement, curly brackets can be ommited.

This is not recomended since it makes code less readable and adding additional code statements can lead to errors.


- Syntax:

- if (condition) { code }

- if (condition) : code endif;


- Example:

- Creat PHP Console Application Test.php.





$number = 10;

if ($number == 10) { print "Number is 10"; }