Hi,
Control statements are fundamental to programming languages. Control statements permit you to take some action if something is the case, and different action (or no action) otherwise. There are three common control statements in PHP:
if . . . else: As the words suggest, this statement tests if something is true. If it is, then it does one thing, else it does another thing. The else part can be omitted. For example,
PHP Code:
$IP_address = getenv("REMOTE_ADDR");
if ( $IP_address == "121.114.221.111" ) {
echo "Hello, George. Welcome to my web site.");
}
else {
echo "Howdy, stranger.";
}
$temperature = 71;
if ( $temperature >= 50 ) {
echo "Nice day!";
}