PHP overview.ppt
-
Upload
hanumant-pujar -
Category
Documents
-
view
238 -
download
0
Transcript of PHP overview.ppt
-
PHP OVERVIEW
-
CONTENT
Introduction of PHP
History and development
Basics of PHP programming
-
WHAT IS PHP ?PHP = Hypertext preprocessor
Server side scripting language
Used for development of dynamical webpagesPart of typical LAMP combination Linux, Apache, MySQL and PHP
Includes a command line scripting possibilityCan be used in graphical applications
-
HOW IT WORKSPHP code is usually embedded into HTML
Processing the code :The HTML code stands as it is
The PHP scripts are executed to create final HTML code
Both parts are combined and back
Resulting HTML is interpreted by a browser
-
ADVANTAGES OF PHP
Freely available The PHP group provides complete source code free of chargeSimilar syntax to C, PearlWorks with many operating systemsCan be deployed on many web serversInteracts with lots of databasesIt is supported by many providers of webhosting
-
HISTORY INITIAL DEVELOPMENTOriginally created by Rasmus LerdorfPHP originally stood for Personal Home PageReplaces small set of Pearl scriptsUsed as a tool for observing traffic on webpage
PHP 2 (PHP/FI)First publicly released version (on June 8, 1995)Combination of Lerdorfs Form Interpreter and original binary from PHP Was able to communicate with databasesEnabled the building of dynamical web applicationincluded Perl-like variables, form handling, and the ability to be embedded HTML
-
HISTORY RELEASED VERSIONSPHP 3The scripting core was rewritten by Zeev Suraski and Andi GutmansThe name was changed to Hypertext preprocessorIt is able to work with MS Windows and Macintosh
PHP4Added Zend engineIntroduced 'superglobals' ($_GET)
None of these versions is under development now
-
CURRENT VERSION - PHP 5
The most recent extension (the 5.2.6) was published on May 1, 2008Uses enhanced Zend II engine
It includes :support for object-oriented programming, the PHP Data Objects extension (simplifies accessing databases)numerous performance enhancements
-
WEBSITES USING PHP
More than 20 million Internet domains are hosted on servers with PHP installed
Significant examlesUser-facing portion of Facebook Wikipedia (MediaWiki) Yahoo! MyYearbook
-
WHAT DO YOU NEED TO WORK WITH PHP?
If your server supports PHP You dont need anythingJust create some .php files in your web directory
If your server does not support PHP, you must install PHP. Download PHPDownload database (MySQL)Download server (Apache)
-
BASICS OF SYNTAXScripting block starts with
Each code line in PHP must end with a (;)
Comments// ,# comment/* comment */Writing of the plain textEcho textprint text
-
VARIABLES IN PHPEach variable starts with $ symbol
Variable name can contain only a-Z,0-9,_
It does not need to be declared before its setting.
-
VARIABLE TYPES
NumericalInteger positive as well as negative, including 0Float real numbers, 14 digits accuracy
Logical Boolean - True x False, not case sensitive
Alphabetical String set of characters
-
WORKING WITH VARIABLESSettype($var, integer)allows you to set variable according to your wishGettype() write the type of variable
(.) Connects 2 variables of string typestrlen() finds the length of a string
-
PHP OPERATORSUses standard mathematical operators +,-,/,* Special symbol ++ (--) for increase (decrease) by 1
Comparison operators >,=Special cases == is equal!= is different
Assignment operators x+=y x=x+y
-
LOGICAL OPERATORS
&& = and|| = orAt least one of condition is fulfilled! = notxorExactly one statement is evaluated as true
-
CONDITIONAL STATEMENTSIf/ else After each statement stands (;) If more than one command should be executed, use curly braces { }
Switch / breakUsed for choosing one possibility from multiple casesSwitch ($var ){ case : x : echo good; break;default : echo wrong input ;}
-
ARRAYS IN PHP
Numeric arrayEach element of array has its ID number (first 0!!)$names = array("Petr,"Joe");$names[0] = "Petr";
Associative ArraysEach element is assigned its value$ages = array("Peter"=>32, "Joe"=>34);$ages['Peter'] = "32";
-
MULTIDIMENSIONAL ARRAYSelement of array is also an array
$families = array ("Griffin"=>array ( "Peter", "Lois", "Megan" ), "Soltis" =>array(Johny", "Morgan" ))
- PHP LOOPINGwhile loops repeat until final condition is reached$i =1;while ($i
-
PHP LOOPINGfor Repeats the specific part of code so many times we choose
for ($i=1; $i
-
HTML INSIDE PHPIf inside quotes, the Html tags are returned as a text by PHP moduleTreated as a HTML tag by
-
PHP FUNCTIONS
All function starts with function($parameter)Requirements for naming functions are same as these for variables The { mark opens the function code, while }mark closes itIt can have either defined or no parameter
More than 700 built-in functions available
-
PHP FORMS AND USER INPUTUsed to gain information from users by means of HTMLInformation is worked up by PHP
Name: Age:
-
THE $_GET VARIABLEUsed to collect values from a formDisplays variable names and values are in the URLhttp://www.w3schools.com/welcome.php?name=jo&age=39Can send limited amount of information (max. 100 characters)
Welcome You are years old
-
THE $_POST VARIABLEUsed to collect values from a formInformation from a form is invisiblehttp://www.w3schools.com/welcome.phpNo limits on the amount of information to be send
Welcome You are years old.
-
THANK YOU FOR YOUR ATTENTION !
-
SOURCEShttp://www.w3schools.com/PHP/http://en.wikipedia.org/wiki/PHPhttp://cz.php.net/http://www.linuxsoft.cz/