August 2000
Intermediate to advanced
800 pages
13h 15m
English
PHP allows you to test conditions and execute certain code based on the result of the test. The simplest form of this is the if statement. Listing 1.6 showshow you can customize the content of a page based on the value of a variable.
The Today variable is set with the name of today's weekday. The if statement evaluates the expression inside the parentheses as either true or false. The == operator compares the left side to the right side. If Today contains the word Friday, the block of code surrounded by curly braces ({ and }) is executed. In all other cases the block of code associated with the else statement is executed.
Read now
Unlock full access