September 2024
Intermediate to advanced
743 pages
27h 48m
English
A PHP script consists of a sequence of statements. These statements can be grouped into statement groups by enclosing them in curly brackets. Let’s start with the if-else construct.
PHP provides an if statement similar to the C language. Recall that the predefined $_GET variable contains all the parameters included in the URL. As shown in Listing 15.18, isset() checks whether the firstName parameter was passed. If yes, the parameter will be written to a variable. If no, a message will be output.
<?phpif ( ! isset( $_GET['firstName'] ) ) { echo 'Please enter a first name!';} else { $firstName = $_GET['firstName'];}
Listing 15.18 Simple Example of an If-Else Statement
As shown ...
Read now
Unlock full access