PHP simple if statement

if statement in php is similar to almost all languages, and it necessary to make a usefull script.

If statement enable you to execute a script only if a condition is true.

Simple if statement:

php code:
<?php
$age = 28;

if ($age == 28)
echo "hello ! Your age is 28";
?>
Display:
hello ! Your age is 28

But if you want to do many lines of code under the if statement, you should do:

php code:
<?php
$age = 28;

if ($age == 28)
{
echo "hello ! Your age is 28";
echo "
" ;

echo "You are wellcome !";

?>
Display:
hello ! Your age is 28
You are wellcome !

0 comments: