PHP Tutorials - Herong's Tutorial Examples - v5.17, by Herong Yang
"if" Statements
This section describes 4 forms of 'if' statements supported in PHP. The more complex form is 'if ... elseif ... else'.
There are 4 forms of "If" statements supported in PHP:
1. Single-statement "if":
if (condition) statement
where "condition" is a Boolean value, and "statement" specify another statement. The specified statement will be executed, if and only if the specified condition is evaluated to "TRUE".
2. Multi-statement "if":
if (condition) { statement; statement; ... }
The specified multi-statement block will be executed, if and only if the specified condition is evaluated to "TRUE".
3. "if ... else" Statement:
if (condition) { statement; statement; ... } else { statement; statement; ... }
Two statement blocks are specified. But only one statement block will be executed based on the value of the specified condition. If the specified condition is "TRUE", the first block will be executed. If the specified condition is "FALSE", the second block will be executed.
4. "if ... elseif" Statement:
if (condition_1) { statement; statement; ... } elseif (condition_2) { statement; statement; ... } elseif (condition_3) { statement; statement; ... ... } else { statement; statement; ... }
Many statement blocks are specified. But only one statement block will be executed based on the value of the condition specified for that block.
Table of Contents
Introduction and Installation of PHP
PHP Data Types and Data Literals
Variables, References, and Constants
Expressions, Operations and Type Conversions
►Conditional Statements - "if" and "switch"
Loop Statements - "while", "for", and "do ... while"
Function Declaration, Arguments, and Return Values
Interface with Operating System
Introduction of Class and Object
Integrating PHP with Apache Web Server
Retrieving Information from HTTP Requests
Creating and Managing Sessions in PHP Scripts
Sending and Receiving Cookies in PHP Scripts
Controlling HTTP Response Header Lines in PHP Scripts
MySQL Server Connection and Access Functions
Functions to Manage Directories, Files and Images
SOAP Extension Function and Calling Web Services
SOAP Server Functions and Examples
Localization Overview of Web Applications
Using Non-ASCII Characters in HTML Documents
Using Non-ASCII Characters as PHP Script String Literals
Receiving Non-ASCII Characters from Input Forms
"mbstring" Extension and Non-ASCII Encoding Management
Managing Non-ASCII Character Strings with MySQL Servers
Parsing and Managing HTML Documents
Configuring and Sending Out Emails
Managing PHP Engine and Modules on macOS