2. Instructor
Name: Mohamed Saad.
Email: Engsaad_aly@hotmail.com
Occupation: Web Developer In IT Big Dig.
PHP Course
Info@ITBigDig.com
3. Contents
• PHP Array
o Introduction.
• Conditional Statements.
o if statement.
o if...else statement.
o if...else if....else statement.
o switch statement.
PHP Course
Info@ITBigDig.com
4. PHP Array
• There are three types of arrays:
Indexed arrays
•Arrays with numeric index
Associative arrays
• Arrays with named keys
Multidimensional
arrays
•Arrays containing one or more arrays
8. Conditional Statements
1) if statement - executes some code only if a specified
condition is true.
2) if...else statement - executes some code if a condition is
true and another code if the condition is false.
3) if...else if....else statement - selects one of several blocks
of code to be executed.
4) switch statement - selects one or more of many blocks
of code to be executed.
9. if statement
Syntax
o if (condition)
{
code to be executed if condition is true;
}
PHP Course
Info@ITBigDig.com
16. Key
"seconds"
"minutes"
"hours"
"mday"
"wday"
"mon"
Returned Values
0 to 59
0 to 59
0 to 23
1 to 31
0 (for Sunday)
1 through 12
"year"
Examples: 1970 or 2011
"yday"
0 through 365
"weekday"
Sunday through Saturday
"month"
January through December
0
Unix Epoch: is a system for describing points in time
-2147483648 through 2147483647.
20. Is Associative
• If set to FALSE or not supplied then the array is
returned as a regular, numerically indexed array. If
the argument is set to TRUE then localtime() returns
an associative array containing all the different
elements of the structure returned by the C function
call to localtime.
23. <?php
Copy PHP Code
if (empty($_POST)===false)
{
$x=$_POST['x'];
if ($x>50){
echo 'U Entered Number ',$x,' greater than 50','<br>';
exit();
}
else
{
echo 'U Entered Number ',$x,' less than 50','<br>';
exit();
}
}
?>
29. Switch statement
Syntax
o switch (n)
{
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
default:
code to be executed if n is different from both
label1 and label2;
}
30. Switch statement
Power Syntax
o switch (variable)
{
case (condition):
code to be executed if condition is true;
break;
case (condition):
code to be executed if condition is true;
break;
default:
All conditions are false;
}
31.
32. <?php
$x="red";
switch ($x)
{
case "blue":
echo "Your favorite color is blue!";
break;
case "red":
echo "___________________<br>";
echo "Your favorite color is red!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "no matching color!";
}
Copy Code
switch2.php
?>
PHP Course
Info@ITBigDig.com
34. <?php
Copy Code
switch.php
$hours = date("H");
$hours=$hours-2;
echo $hours,date(":i:s");
echo "<br/>";
?>
<?php
switch ($hours)
{
case ($hours>5 and $hours<6):
echo "it is the time of the TV News <br/>";
case ($hours>=6 and $hours<8):
echo "Read something<br/>";
case ($hours>=8 and $hours<10):
echo "PlayStation time<br/>";
default:
echo "GoodNight";
}
?>
PHP Course
Info@ITBigDig.com
35. Character
Description
Expected O/P
d
Day of the month,
j
Day of the month without leading
zeros
D
l
A textual representation
of a day
2 digits
Returned Values
01 to 31
1 to 31
Three letters Mon through Sun
A full textual representation of the day Sunday through
of the week it is lowercase “L”
Saturday
N
ISO-8601 numeric
representation of the day
of the week (PHP 5.1.0)
S
English ordinal suffix for
the day of the month,
z
The day of the year
1 digit
1 (for Monday)
through 7 (for
Sunday)
2 characters st, nd, rd or th.
0 through 365
36. For complete reference Go To
http://php.net/manual/en/function.date.
php
PHP Course
Info@ITBigDig.com
37. End
Conditional Statements
We hope You enjoy This Tutorial.
For any Suggestions Please Email Us
Info@ITBigDig.com
PHP Course
Info@ITBigDig.com