3.2. Control Structures and Operators

Usually programs need so-called control structures, which are used to decide at runtime what a program has to do. Flow control is an important part of every programming language and is essential for building applications. PHP provides a broad range of methods, as you will see in this section.

3.2.1. Operator and IF/ELSE/ELSEIF Statements

Use if to check whether a certain expression is true or not. If is supported by all commonly used programming languages such as C/C++, Java, Perl, and Python, and therefore it is a fundamental instrument of every computer programmer. To show you how conditions can be checked using if, we include a short example:

<?php
        if      (2 > 1)
        {
                echo '2 is higher than 1<br>';
        }
?>

A message ...

Get PHP and PostgreSQL: Advanced Web Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.