PHP Process Control, PHP process
Php-if statements
The IF statement is used to execute code only when the specified condition is true .
Grammar
if (condition) {The code to execute when the condition is established;}
If the current time is less than 20, the following instance will output "a good day!" :
Instance
Run
Php-if...else statements
Execute a piece of code when the condition is established, and execute another piece of code when the condition is not established , using the If....else statement.
Grammar
if (condition) {code executed when the condition is established;} Code executed when the else{condition is not established;}
If the current time is less than 20, the following instance outputs "a good day!", otherwise the output "has a good night!" :
Php-if...else if....else Statements
To execute a block of code when one of several conditions is established , use the If....else if...else statement:
Grammar
if (condition) {The code executed when the condition is established;} else if (condition) {ElseIf code executed when the condition is established;} Code executed when the else{condition is not established;}
If the current time is less than 10, the following instance will output "a good morning!", if the current time is not less than 10 and less than 20, the output "has a good day!", otherwise the output "has a good night!" :
Original address: http://www.manongjc.com/php/php_if_switch.html
Related reading:
PHP date_sunrise () Get Sunrise time based on location (longitude latitude)
PHP Global legal time zone list Daquan
PHP Date_default_timezone_set () sets the default time zone for date/time functions
PHP date_default_timezone_get () Gets the default time zone used by the DateTime function
PHP checkdate () function verifies that the date is valid (correct)
Climbing Mount Tai To see the sunrise must-Taishan Sunrise time list
http://www.bkjia.com/PHPjc/1131138.html www.bkjia.com true http://www.bkjia.com/PHPjc/1131138.html techarticle PHP Process Control, PHP flow php-if statement If statement is used to execute code only when the specified condition is true. Syntax if (condition) {The code to execute when the condition is set;} If the current time is less than ...