Download presentation
Presentation is loading. Please wait.
Published byJulia Ball Modified over 9 years ago
2
PHPPHP What is PHP? Hypertext Pre-processor (PHPs) is a server- side scripting language In early versions, PHP stand for Personal Home Page. server-side scripts are special commands that can place in Web pages. Those commands are processed before the pages are sent to the Web browser PHP is an HTML-embedded scripting language
3
PHPPHP The goal of the language are It can generate dynamic pages Can collect data from the form Can add, delete, modify data in database Can encrypt data
4
PHPPHP Php can run diff platforms (win, linux, Unix,Mac Os,etc…) Php is compatible with almost all servers Php support wide range of data bases Ph, is fee to download from www.php.netwww.php.net Php is easy to learn and run efficiently on the server side
5
PHPPHP WAMP Is a packages stands for Windows, Apache, MySQL, and PHP Operating System (Windows), Web Server (Apache), database (MySQL), and scripting language (PHP, Perl, or Python).
6
PHPPHP LAMP stands for Linux, Apache, MySQL, and PHP. Operating System (Linux), Web Server (Apache), database (MySQL), and scripting language (PHP).
7
PHPPHP PHP files are usually given the ".php" extension. PHP script can be placed anywhere in the html page Php script start with Eg <?php echo(“popo”); ?>
8
PHPPHP PHP – Variables A variable start with $ sign followed by name of the variable In PHP a variable with the following form: $variable_name = Value; $a= 25; $b=$a+3; $c = “popo";
9
PHPPHP <?php //--------------TESTING VARIABLES------------ $test_String = "It popo"; echo($test_String); ?>
10
PHPPHP The full stop (period or dot) is used to join strings and variables <?php $number = 10; $text = “variable value”; echo ($text. $number); ?>
11
PHPPHP PHP – echo To output a string. You can place either a string variable or you can use quotes. It can include html tags. <?php $String = "Hello!"; echo $String; echo " I love using PHP! "; ?>
12
PHPPHP PHP – Operators Arithmetic Operators +-*/% Comparison Operators == Equal To$x == $y != Not Equal To$x != $y < Less Than$x < $y >Greater Than$x > $y <= Less Than or Equal To$x <= $y >= Greater Than or Equal To$x >= $y
13
PHPPHP PHP Include menu.php Code: Home About Us ----------------------------------------------------------------------- ----- index.php Code: This is my home page/p>
14
PHPPHP PHP If Statement $my_name = “popo"; if ( $my_name == “popo" ) { echo "Your name is popo! "; } echo "Welcome to my homepage!";
15
PHPPHP If/else $number_three = 3; if ( $number_three == 3 ) { echo "The if statement evaluated to true"; } else { echo "The if statement evaluated to false"; }
16
PHPPHP Creating the HTML Form Index.html Login Form Name Sex Male Female Place Menu.php <?php $u = $_POST["user"]; $s = $_POST["sex"]; $p= $_POST["place"]; echo "You Name ". $u. " Sex ".$s." Place".$p; ?> ----------------------- If the method is get $u=$_GET[“user”];
17
PHPPHP PHP – Functions <?php function popo() { echo "I am POPO! "; } popo(); ?> ----------------------------------------------------------------------------------------- Fun with arg <?php function popo($f){ echo "Hello there ". $f. "! "; } popo("popo"); ?>
18
PHPPHP PHP Array <?php $A [0] = "0"; $A [1] = "1" ; $A [2] = "2" ; $A [3] = "3" ; $A [4] = "4" ; $A [5] = "5" ; for($i=0;$i<5;$i++) { echo ($A [$i]." "); } ?>
19
PHPPHP PHP - For Loop <?php echo " "; echo " POPO "; for ( $i = 10; $i <= 100; $i ++) { echo " ". $i; } echo " "; ?>
20
PHPPHP Time "am" or "pm" "AM" or "PM" Day of the month: 01 to 31 Day of the week: Sun, Mon, Tue, Wed, Thu, Fri, Sat Month: January, February, March... Hour: 01 to 12 Hour: 00 to 23
21
PHPPHP Time Hour: 1 to 12 Minutes: 00 to 59 1 to 31 Day of the week: Sunday, Monday,. Month: 1 to 12 Month: Jan, Feb, Seconds: 00 to 59 Year (four digits) Year (two digits)
22
PHPPHP echo date("m/d/y"); 02/05/13 echo date(“F/d/y"); February/014/13 echo date("F/D/Y"); February/Thu/2013 ---------------------------------------------------------------
23
PHPPHP intval() return integer value $a="10"; $b="4"; $l=intval($a)+intval($b); echo(" ".$l); ------------------------------------------------------------------ floatval() return float value $a=“10.2”; $b=floatval($a); echo (“ ”.$b);
24
PHPPHP Example switch & include() Index.php Check.php <?php $a=$_GET['no']; switch(intval($a)) { case 1: include("1.php");break; case 2: include("2.php");break; default :include("3.php");break; } ?> 1.Php one.php 1.Php one.php 1.Php one.php
25
PHPPHP Questions Addition of two nos (using form) Biggest among 3 nos(using form) Print first n Nos where even in red and odd in green color (using form) Print the given no in words (using form)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.