First Tutorial ...
Beginning...
Second PHP article.
Article's Objectives:
- Learn variables
- Learn IF,ELSE and ELSEIF
- Make little '18+ Age Control' example
Variables
Variables, like a box. You can make any value in box. For example (toys,ball,name vs).
<?php
$thisisvariable = "This is variable";
?>
You can use variables IN ANY PHP FUNCTION.
<?php
$name = "Eray";
echo "My name is ".$name;
?>
IF Clause
IF
First if clause tag is 'IF'. IF you want check some variables you can use 'IF'. For example;
<?php
if(1 == 2)
{
echo "Math is broken!";
}
?>
ELSE
ELSE is IF's reverse. Other name is IFNOT
<?php
if(1 == 2)
{
echo "Math is broken!";
}
else
{
echo "Absolute, wrong!";
}
?>
ELSEIF
Elseif is mean ' ELSE AND IF '.You can write else after if but ELSEIF small and lite.<?php
$user= "Man";
if($user== "Man")
{
echo("Hello Mr.");
}
elseif($user == "Woman")
{
echo("Hello Mrs.");
}
else
{
echo("Hello!");
}
?>
Age Control System
In age control system, we use IF,ELSE,ELSEIF and VARIABLES.We must start PHP tag
<?phpAfter we set a age variable
$age = 18;When we set age, we check if age bigger then 18
if($age > 18)We check if age equals 18
{
echo("You can use site");
}
<?phpEnd we check if age smaller then 18(if is not 18 and >18)
elseif($age == 18)
{
echo("You must age 1 more year");
}
?>
<?php
else
{
echo("You must wait too long...");
}
?>
Homework ( Ohh No! )
- Make small login panel (username : phpfast | password : fastphp) (Not login form only variables)
0 yorum:
Yorum Gönder