Successfully reported this slideshow.

GettingStartedWithPHP

1,024 views

Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

GettingStartedWithPHP

  1. 1. Getting Started With PHP
  2. 2. Install Webserver Linux http://www.apachefriends.org/en/xampp-linux.html
  3. 3. An introductory example <!DOCTYPE HTML PUBLIC "-//W3C// DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd"> <html>     <head>         <title>Example</title>     </head>     <body>         <?php             echo "Hi, I'm a PHP script!";         ?>     </body>
  4. 4. Our first PHP script
  5. 5. Our first PHP script <html>  <head>   <title>PHP Test</title>  </head>  <body>  <?php echo '<p>Hello World</p>'; ?>   </body> </html>
  6. 6. Our first PHP script <html>  <head>   <title>PHP Test</title>  </head>  <body>  <p>Hello World</p>  </body> </html>
  7. 7. Get system information from PHP <?
  8. 8. PHP Variables <?php $var = 'Bob'; $Var = 'Joe'; echo "$var, $Var"; // outputs "Bob, Joe" // invalid; starts with a number $4site ='not yet';  ?>
  9. 9. Reference Variable <?php // Assign the value 'Bob' to $foo $foo = 'Bob';   // Reference $foo via $bar. $bar = &$foo;       // Alter $bar...         $bar = "My name is $bar";   echo $bar; // $foo is altered too. echo $foo;                  ?>
  10. 10. PHP Arrays $ php array.php Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => a [7] => b [8] => cat [9] => dog )
  11. 11. PHP Arrays & For loop
  12. 12. PHP Arrays & Foreach
  13. 13. For loop vs Foreach
  14. 14. For loop vs Foreach
  15. 15. For loop vs Foreach
  16. 16. For loop vs Foreach
  17. 17. PHP : Functions <?php function a($n){   b($n);   return ($n * $n); } function b(&$n){   $n++; } echo a(5); //Outputs 36 ?>
  18. 18. PHP: Functions (global statement) <?php $foo = 1; bar(); // call function function bar() { global $foo; $foo++; echo "$foo in function bar() = " . $foo."n"; } echo "$foo in main = " . $foo."n"; ?> Outputs $foo in function bar() = 2 $foo in main = 2
  19. 19. Standard Input (Keyboard) echo "Enter Username : "; $username = fgets (STDIN, 1024); echo "Enter Password : "; $password = fgets (STDIN, 1024);
  20. 20. Standard Functions array_push trim print_r var_dump
  21. 21. My website http://www.together.in.th

×