Task : Based on Topic 8 and 9 on PHP examples, create your own exercises using different values and layout.
PHP is popular and its use in increasing rapidly because several advantages.
PHP is popular and its use in increasing rapidly because several advantages.
- Easy to use - is like C,C++, Java and Perl.
- PHP is secure and easy to learn.
- It's easier to learn than C, Phyton, Java and most other programming languages used in web development for that matter.
- Open source - it is available for free download over the Internet. The program code is available to view and change if really desire.
- Multiple platform - PHP can be installed on UNIX or Windows - based machines.
- Language support for databases - PHP supports a variety of diffrent system that include MySQL, Informix, Oracle, Sybase to name a few.
Example 1
<html> Server Side Script : PHP
<?php
echo "<h1> Hello, World!</h1>";
?>
</html>
Example 2 (Operators)
<html>
<?php
$x = 4;
$y = 5;
if ($x == 4 && $y == 4)
echo "X is equal to Y";
else
echo "X is not equal to Y";
?>
</html>
Example 3 (Conditional Statements and Loops)
<html>
<?php
$a = 0;
echo "for loop <br>";
for ($i=0; $i < 5; $i++)
{
$a += 5;
echo "Value $i = $a <br>";
}
?>
</html>
Example 4 (Function)
<html>
<?php
function go()
{
echo"PHP adds dynamic content<hr>";
}
echo "** HTML is great for static content **";
echo "<hr>";
go();
echo "<hr>";
go();
?>
</html>
Example 5 (Arrays)
<html>
<?php
$CarInfo = array("Unser", "2002", 34500);
echo $CarInfo[2]; //display value of index 2 (or 3rd element)
echo "<p>";
print_r($CarInfo); //display all index and its value
?>
</html>





Comments
Post a Comment