SlideShare a Scribd company logo
Web Server Web server: IIS, Apache Script Language: ASP, PHP.. Database: mysql, mssql…
Operation Principles
What is PHP? PHP stands for  P HP:  H ypertext  P reprocessor. PHP is a server-side scripting language, like ASP -PHP scripts are executed on the server  -PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)  -PHP is an open source software  -PHP is free to download and use
What is a PHP File? -PHP files can contain text, HTML tags and scripts. -PHP files are returned to the browser as plain HTML. -PHP files have a file extension of ".php", ".php3", or ".phtml“.
What is MySQL? -MySQL is a database server. -MySQL is ideal for both small and large applications. -MySQL supports standard SQL. -MySQL compiles on a number of platforms. -MySQL is free to download and use.
LAMP L : Linux(Fedora, CentOS, Debian, Ubuntu). A : Apache. M : Mysql. P : PHP.
PHP Syntax <?php   echo &quot;Hello World&quot;; ?> //This is a comment /* This is a comment block */
PHP Variables $var_name = value; <?php $txt=&quot;Hello World!&quot;; $x=16; ?>  a-z, A-Z, 0-9, and _
PHP String Variables <?php   $txt=&quot;Hello World&quot;;   echo $txt;// Hello World ?>  <?php   $txt1=&quot;Hello World!&quot;;   $txt2=&quot;What a nice day!&quot;;   echo $txt1  .  &quot; &quot; . $txt2; ?> <?php   echo strlen(&quot;Hello world!&quot;); // 12 ?>  <?php   echo strpos(&quot;Hello world!&quot;,&quot;world&quot;); //6 ?>
PHP Operators -Arithmetic Operators -Assignment Operators - Comparison Operators   -Logical Operators
PHP Operators (Arithmetic)
PHP Operators (Assignment   )
PHP Operators (Comparison)
PHP Operators (Logical)
PHP If...Else Statements if ( condition )    code to be executed if condition is true; else    code to be executed if condition is false;   <?php $d=date(&quot;D&quot;); if ($d==&quot;Fri&quot;)   echo &quot;Have a nice weekend!&quot;; else   echo &quot;Have a nice day!&quot;; ?>
PHP Switch Statement 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; }
PHP Switch Statement(Cont) <?php switch ($x) { case 1:   echo &quot;Number 1&quot;;   break; case 2:   echo &quot;Number 2&quot;;   break; case 3:   echo &quot;Number 3&quot;;   break; default:   echo &quot;No number between 1 and 3&quot;; } ?>
PHP Arrays Numeric array  - An array with a numeric index. * $cars=array(&quot;Saab&quot;,&quot;Volvo&quot;,&quot;BMW&quot;,&quot;Toyota&quot;);  Associative array  - An array where each ID key is associated with a value * $ages = array(&quot;Peter&quot;=>32, &quot;Quagmire&quot;=>30, &quot;Joe&quot;=>34);  Multidimensional array  - An array containing one or more arrays. * $families = array (&quot;Griffin&quot;=>array (&quot;Peter&quot;,&quot;Lois&quot;,&quot;Megan&quot;),  &quot;Quagmire&quot;=>array(&quot;Glenn&quot;) );
PHP Looping - While Loops while ( condition ) {   code to be executed ; }  <?php $i=1; while($i<=5) {   echo &quot;The number is &quot; . $i . &quot;<br />&quot;; $i++; } ?>   do   {   code to be executed;    } while ( condition ); <?php $i=1; do   {   $i++;   echo &quot;The number is &quot; . $i . &quot;<br />&quot;;   } while ($i<=5); ?>
PHP Looping - For Loops for ( init; condition; increment ) {    code to be executed; }  <?php for ($i=1; $i<=5; $i++) {   echo &quot;The number is &quot; . $i . &quot;<br />&quot;; } ?> foreach ($ array  as   $ value )  {    code to be executed;  } <?php $x=array(&quot;one&quot;,&quot;two&quot;,&quot;three&quot;); foreach ($x as $value) {   echo $value . &quot;<br />&quot;; } ?>
PHP Functions function  functionName () {   code to be executed ; } <?php function writeName() { echo &quot;Kai Jim Refsnes&quot;; } echo &quot;My name is &quot;; writeName(); ?>  <html> <body> <?php function &add($x,$y) {   $total=$x+$y;   return $total; } echo &quot;1 + 16 = &quot; . add(1,16); ?> </body> </html>
PHP Forms and User Input <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html>  <html> <body> Welcome <?php echo $_POST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_POST[&quot;age&quot;]; ?> years old. </body> </html>
PHP $_GET Function <html> <body> <form action=&quot;welcome.php&quot; method=“get&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html>  <html> <body> Welcome <?php echo $_GET[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_GET[&quot;age&quot;]; ?> years old. </body> </html>  http://www.dqn.vn/welcome.php?fname=Peter&age=37
PHP $_POST Function <html> <body> <form action=&quot;welcome.php&quot; method=“post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html>  <html> <body> Welcome <?php echo $_POST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_POST[&quot;age&quot;]; ?> years old. </body> </html>  http://www.dqn.vn/welcome.php.
The PHP $_REQUEST Function The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. Welcome <?php echo $_REQUEST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_REQUEST[&quot;age&quot;]; ?> years old.
PHP With Database mysql_connect (&quot;localhost&quot;, &quot;mysql_user&quot;, &quot;mysql_password&quot;) or     die(&quot;Could not connect: &quot; . mysql_error()); mysql_select_db (&quot;mydb&quot;); $result =  mysql_query (&quot;SELECT id, name FROM mytable&quot;); while ($row =  mysql_fetch_array ($result)) {     printf(&quot;ID: %s  Name: %s&quot;, $row[0], $row[1]);   } mysql_free_result ($result);  mysql_close() ;

More Related Content

PPTX
Php Tutorial
PPT
PHP - Introduction to PHP - Mazenet Solution
PPT
Introduction to PHP
PPT
Php Calling Operators
PPT
Php Lecture Notes
PPT
Php Rss
PDF
07 Introduction to PHP #burningkeyboards
Php Tutorial
PHP - Introduction to PHP - Mazenet Solution
Introduction to PHP
Php Calling Operators
Php Lecture Notes
Php Rss
07 Introduction to PHP #burningkeyboards

What's hot (20)

PPT
PHP - Introduction to PHP
PPT
PHP POWERPOINT SLIDES
PPT
02 Php Vars Op Control Etc
PPTX
Php.ppt
PPT
Php(report)
PPTX
Php basics
PDF
Php tutorial(w3schools)
PPT
Introduction To Php For Wit2009
PPT
PPT
Chapter 02 php basic syntax
PDF
Introduction to PHP - Basics of PHP
PDF
basic concept of php(Gunikhan sonowal)
PPTX
Intro to php
PPTX
PPTX
PPT
01 Php Introduction
PPTX
PHP tutorial | ptutorial
PPT
Download It
PHP - Introduction to PHP
PHP POWERPOINT SLIDES
02 Php Vars Op Control Etc
Php.ppt
Php(report)
Php basics
Php tutorial(w3schools)
Introduction To Php For Wit2009
Chapter 02 php basic syntax
Introduction to PHP - Basics of PHP
basic concept of php(Gunikhan sonowal)
Intro to php
01 Php Introduction
PHP tutorial | ptutorial
Download It
Ad

Viewers also liked (20)

PPTX
The arrival in manila
PPT
Hong Kong, Second Homecoming & La Liga Filipina
PPT
PHP MySQL Workshop - facehook
PPTX
SocSci- Rizal as a Traveler
PPTX
El filibusterismo
PPTX
Rizal's life by Cabsag Naisy BSED3
PPTX
Environmental principles
PPTX
Importance of Hotels and Tourism in India
DOCX
Epekto ng Oplayn na Laro
DOC
Filipino inside
PPT
Rizal and other heroes heroines chapter 10 rizal's first home coming 1887-88
PPTX
Non – projected
PDF
Oral versus written assessments
DOCX
Banghay Aralin sa pagtuturo ng filipino
PPTX
PDF
Asean Integration 2015
PPTX
Poems of Rizal
DOC
My Porfolio
PPT
Travels of rizal (1)
PDF
Research Paper on Academic Cheating
The arrival in manila
Hong Kong, Second Homecoming & La Liga Filipina
PHP MySQL Workshop - facehook
SocSci- Rizal as a Traveler
El filibusterismo
Rizal's life by Cabsag Naisy BSED3
Environmental principles
Importance of Hotels and Tourism in India
Epekto ng Oplayn na Laro
Filipino inside
Rizal and other heroes heroines chapter 10 rizal's first home coming 1887-88
Non – projected
Oral versus written assessments
Banghay Aralin sa pagtuturo ng filipino
Asean Integration 2015
Poems of Rizal
My Porfolio
Travels of rizal (1)
Research Paper on Academic Cheating
Ad

Similar to Php Training (20)

PPT
What Is Php
 
PPT
PPT
PHP Tutorials
PPT
PHP Tutorials
PPT
Php Crash Course
PPT
course slides -- powerpoint
PPT
Web development
PPT
Open Source Package PHP & MySQL
PPT
Open Source Package Php Mysql 1228203701094763 9
PPT
php41.ppt
PPT
PHP InterLevel.ppt
PPT
php-I-slides.ppt
PPT
Php basic for vit university
PPT
PHP Workshop Notes
PPT
Babitha5.php
PPT
Babitha5.php
PPT
Babitha5.php
What Is Php
 
PHP Tutorials
PHP Tutorials
Php Crash Course
course slides -- powerpoint
Web development
Open Source Package PHP & MySQL
Open Source Package Php Mysql 1228203701094763 9
php41.ppt
PHP InterLevel.ppt
php-I-slides.ppt
Php basic for vit university
PHP Workshop Notes
Babitha5.php
Babitha5.php
Babitha5.php

Php Training

  • 1. Web Server Web server: IIS, Apache Script Language: ASP, PHP.. Database: mysql, mssql…
  • 3. What is PHP? PHP stands for P HP: H ypertext P reprocessor. PHP is a server-side scripting language, like ASP -PHP scripts are executed on the server -PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) -PHP is an open source software -PHP is free to download and use
  • 4. What is a PHP File? -PHP files can contain text, HTML tags and scripts. -PHP files are returned to the browser as plain HTML. -PHP files have a file extension of &quot;.php&quot;, &quot;.php3&quot;, or &quot;.phtml“.
  • 5. What is MySQL? -MySQL is a database server. -MySQL is ideal for both small and large applications. -MySQL supports standard SQL. -MySQL compiles on a number of platforms. -MySQL is free to download and use.
  • 6. LAMP L : Linux(Fedora, CentOS, Debian, Ubuntu). A : Apache. M : Mysql. P : PHP.
  • 7. PHP Syntax <?php echo &quot;Hello World&quot;; ?> //This is a comment /* This is a comment block */
  • 8. PHP Variables $var_name = value; <?php $txt=&quot;Hello World!&quot;; $x=16; ?> a-z, A-Z, 0-9, and _
  • 9. PHP String Variables <?php $txt=&quot;Hello World&quot;; echo $txt;// Hello World ?> <?php $txt1=&quot;Hello World!&quot;; $txt2=&quot;What a nice day!&quot;; echo $txt1 . &quot; &quot; . $txt2; ?> <?php echo strlen(&quot;Hello world!&quot;); // 12 ?> <?php echo strpos(&quot;Hello world!&quot;,&quot;world&quot;); //6 ?>
  • 10. PHP Operators -Arithmetic Operators -Assignment Operators - Comparison Operators -Logical Operators
  • 15. PHP If...Else Statements if ( condition )    code to be executed if condition is true; else    code to be executed if condition is false; <?php $d=date(&quot;D&quot;); if ($d==&quot;Fri&quot;)   echo &quot;Have a nice weekend!&quot;; else   echo &quot;Have a nice day!&quot;; ?>
  • 16. PHP Switch Statement 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; }
  • 17. PHP Switch Statement(Cont) <?php switch ($x) { case 1:   echo &quot;Number 1&quot;;   break; case 2:   echo &quot;Number 2&quot;;   break; case 3:   echo &quot;Number 3&quot;;   break; default:   echo &quot;No number between 1 and 3&quot;; } ?>
  • 18. PHP Arrays Numeric array - An array with a numeric index. * $cars=array(&quot;Saab&quot;,&quot;Volvo&quot;,&quot;BMW&quot;,&quot;Toyota&quot;); Associative array - An array where each ID key is associated with a value * $ages = array(&quot;Peter&quot;=>32, &quot;Quagmire&quot;=>30, &quot;Joe&quot;=>34); Multidimensional array - An array containing one or more arrays. * $families = array (&quot;Griffin&quot;=>array (&quot;Peter&quot;,&quot;Lois&quot;,&quot;Megan&quot;),  &quot;Quagmire&quot;=>array(&quot;Glenn&quot;) );
  • 19. PHP Looping - While Loops while ( condition ) { code to be executed ; } <?php $i=1; while($i<=5) {   echo &quot;The number is &quot; . $i . &quot;<br />&quot;; $i++; } ?> do   {   code to be executed;   } while ( condition ); <?php $i=1; do   {   $i++;   echo &quot;The number is &quot; . $i . &quot;<br />&quot;;   } while ($i<=5); ?>
  • 20. PHP Looping - For Loops for ( init; condition; increment ) {    code to be executed; } <?php for ($i=1; $i<=5; $i++) {   echo &quot;The number is &quot; . $i . &quot;<br />&quot;; } ?> foreach ($ array as $ value ) {    code to be executed;  } <?php $x=array(&quot;one&quot;,&quot;two&quot;,&quot;three&quot;); foreach ($x as $value) {   echo $value . &quot;<br />&quot;; } ?>
  • 21. PHP Functions function functionName () { code to be executed ; } <?php function writeName() { echo &quot;Kai Jim Refsnes&quot;; } echo &quot;My name is &quot;; writeName(); ?> <html> <body> <?php function &add($x,$y) { $total=$x+$y; return $total; } echo &quot;1 + 16 = &quot; . add(1,16); ?> </body> </html>
  • 22. PHP Forms and User Input <html> <body> <form action=&quot;welcome.php&quot; method=&quot;post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> <html> <body> Welcome <?php echo $_POST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_POST[&quot;age&quot;]; ?> years old. </body> </html>
  • 23. PHP $_GET Function <html> <body> <form action=&quot;welcome.php&quot; method=“get&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> <html> <body> Welcome <?php echo $_GET[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_GET[&quot;age&quot;]; ?> years old. </body> </html> http://www.dqn.vn/welcome.php?fname=Peter&age=37
  • 24. PHP $_POST Function <html> <body> <form action=&quot;welcome.php&quot; method=“post&quot;> Name: <input type=&quot;text&quot; name=&quot;fname&quot; /> Age: <input type=&quot;text&quot; name=&quot;age&quot; /> <input type=&quot;submit&quot; /> </form> </body> </html> <html> <body> Welcome <?php echo $_POST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_POST[&quot;age&quot;]; ?> years old. </body> </html> http://www.dqn.vn/welcome.php.
  • 25. The PHP $_REQUEST Function The $_REQUEST function can be used to collect form data sent with both the GET and POST methods. Welcome <?php echo $_REQUEST[&quot;fname&quot;]; ?>!<br /> You are <?php echo $_REQUEST[&quot;age&quot;]; ?> years old.
  • 26. PHP With Database mysql_connect (&quot;localhost&quot;, &quot;mysql_user&quot;, &quot;mysql_password&quot;) or     die(&quot;Could not connect: &quot; . mysql_error()); mysql_select_db (&quot;mydb&quot;); $result =  mysql_query (&quot;SELECT id, name FROM mytable&quot;); while ($row =  mysql_fetch_array ($result)) {     printf(&quot;ID: %s  Name: %s&quot;, $row[0], $row[1]);   } mysql_free_result ($result); mysql_close() ;