Your SlideShare is downloading. ×
0
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Php Training
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Php Training

8,464

Published on

php training

php training

0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,464
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
690
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×