PHP Pattadon Sintusak ID. 49541154 1 Content History of PHP What’s PHP? Purpose of PHP Structure of PHP Language Reference Different between PHP and ASP PHP Programming introduction2 HISTORY of PHP PHP stands for “Professional Home Page” It’s first build in 1994 Developer is Mr.Rasmus Lerdorf Nowadays, PHP is the fourth version , The first version was known as Personal Homepage Tools in 1994 to 1995 The second was PHP/FI in middle of 1995 Version 3 was known as PHP3 firstly used in 1997 PHP Programming introduction3 Developers of PHP Zeev Suraski, Israel Andi Gutmans, Israel Shane Caraveo, Florida USA Stig Bakken, Norway Andrey Zmievski, Nebraska USA Sascha Schumann, Dortmund, Germany Thies C. Arntzen, Hamburg, Germany Jim Winstead, Los Angeles, USA Rasmus Lerdorf, North Carolina, USA PHP Programming introduction4 What’s PHP? It’s a Script language for showing webpage , arrange in Server Side Script group like ASP Insert in HTML for working Can compile in UNIX, Windows NT/2000/XP, Windows 9x High efficiency ,especially when connect with Database such as MySQL, msSQL, Sybase and PostgreSQL etc. PHP Programming introduction5 PHP can do !! CGI Database-enable web page Database Adabas D DBase Empress FilePro Informix InterBase mSQL MySQL Oracle PostgreSQL Solid Sybase Velocis Unix dbm PHP Programming introduction6 Purpose of PHP Open source No cost implementation – PHP is free! Server side Crossable Platform HTML embedded Simple language Efficiency XML parsing Server side Database module File I/O Text processing Image processing PHP Programming introduction7 Working of PHP Working on Server Working with HTML Can insert PHP commands as you want in HTML document Show output by Web Browsers PHP Programming introduction8 Language structure of PHP XML style <?php language command PHP ?> Example. <?php echo “Hello World ! <br>”; echo “I am PHP”; ?> PHP Programming introduction9 Language structure of PHP(cont.) SGML style <? Language command PHP ?> Example. <? echo “Hello World ! <br>”; echo “I am PHP”; ?> PHP Programming introduction10 Language structure of PHP(cont.) Java Language style <script language=“php”> language command PHP </script> Example. <script language=“php”> echo “Hello World”; </script> PHP Programming introduction11 Language structure of PHP(cont.) ASP Style <% language command PHP %> Example. <% echo “Hello World ! <br>”; echo “I am PHP”; %> PHP Programming introduction12 Language structure of PHP(cont.) XML style is the most popular style. Output is Hello World ! I am PHP Notice - Language structure is similar to C and Perl - use ( ; ) to end each command. File must save in .php (or php3) PHP Programming introduction13 Language Reference Comments - similar to comment in C, C++ and Unix Example. <?php echo “Hello !”; // comment 1 line /* at least 2 lines */ echo “World”; # comment in shell-style ?> PHP Programming introduction14 “Echo” command is a command for showing output at browser program format echo statement1 or variable1, statement2 or variable2, statement 3 or variable3, … statement is bestrided by double quote (“ “) or single quote (‘ ‘) Variable of PHP always begin with $ like Perl PHP Programming introduction15 Example 1 intro.php <HTML> <HEAD> <TITLE>Example –1</TITLE> </HEAD> <BODY> <?php phpinfo() ; ?> <BODY> </HTML> PHP Programming introduction16 Example 2 (date.php) <HTML> <HEAD> <TITLE> Example –2</TITLE> </HEAD> <BODY> Today’s Date: <? print(Date("l F d, Y")); ?> </BODY> </HTML> Today's Date: Thursday March 10, 2003 PHP Programming introduction17