• Like
Introduction to PHP
Upcoming SlideShare
Loading in...5
×

Introduction to PHP

  • 31,394 views
Uploaded on

An introduction to the PHP programming language.

An introduction to the PHP programming language.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • IT Pathshala, Noida-Sec-63, offers Guaranteed JOB with PHP Training Programs.

    PAY US ONLY IF YOU GET A JOB!

    CALL US - +91-9871350999 or +91-8800394970

    Technology Centre Address: H-110, Sector-63, Noida (UP)

    Program Highlights:

    - 100% Guaranteed Job – Don’t pay us if you don’t get a JOB!
    - Industry Ready Courses
    - LIVE International Project Experience
    - Exposure to corporate culture at our IT services facility
    - Networking & Interaction with Industry Experts
    - Training provided by reputed IT Company
    - Live Project Source Code made available in CD
    - Technology certification and experience letter at program completion
    - Online Study Content
    Program Takeaways:

    - GUARANTEED JOB in your technology domain
    - Live Major Project development
    - Experience Letter on Training Completion
    - Certification on Training Completion
    - Project Source Code available in CD

    CALL US - +91-9871350999 or +91-8800394970

    Our website: www.itpathshala.com
    Are you sure you want to
    Your message goes here
  • Hello, PHP stands for ‘Hypertext Preprocessor’, which is widely used for making dynamic and interactive web pages. PHP is server side scripting language intended to help web developers build dynamic web pages. PHP is the widely-used, free, and efficient alternative to other server scripting languages............. for more details please check out this link..... http://mindstick.com/Articles/33bccb35-3934-4f9e-b89f-e94a434653cc/?Introduction%20of%20PHP

    Thanks !!!!!!!!
    Are you sure you want to
    Your message goes here
  • Nicely done.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
31,394
On Slideshare
0
From Embeds
0
Number of Embeds
15

Actions

Shares
Downloads
901
Comments
3
Likes
19

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. Introduction to PHP Bradley Holt (http://bradley-holt.com/) & Matthew Weier O’Phinney (http:/ /weierophinney.net/matthew/) Feedback: http://joind.in/1976
  • 2. What is PHP? Loosely typed scripting language Interpreted at runtime (use an opcode cache) Commonly used to build web applications
  • 3. Who uses PHP? Yahoo! Facebook 20+ million other domain names
  • 4. Brief History
  • 5. Personal Home Page / Forms Interpreter Created by Rasmus Lerdorf PHP/FI 1.0 released in 1995 PHP/FI 2.0 released in 1997
  • 6. PHP: Hypertext Preprocessor Created by Andi Gutmans and Zeev Suraski PHP 3.0 released in 1998 PHP 4.4 released in 2005
  • 7. PHP 5 New object model PHP 5.0 released in 2004 PHP 5.3 released in 2009
  • 8. Syntax
  • 9. Hello World <?php // hello.php echo 'Hello, VT Code Camp.'; ?>
  • 10. Variable Assignment <?php $hello = 'Hello, VT Code Camp.'; echo $hello;
  • 11. Comments
  • 12. One Line Comments <?php // A one line comment # Another one line comment
  • 13. Multi-Line Comments <?php /* A multi-line comment */
  • 14. DocBlock Comments <?php /** * This function does nothing * * @param string $bar * @return void */ function foo($bar) {}
  • 15. Primitive Data Types <?php $isPhpProgrammer = true; // boolean $howOldIsPhp = 15; // integer $pi = 3.14; // float $event = 'VT Code Camp'; // string
  • 16. Conditionals
  • 17. If <?php if (true) { echo 'Yes'; }
  • 18. If-Then-Else <?php if (false) { echo 'No'; } else { echo 'Yes'; }
  • 19. If-Then-Else-If <?php if (false) { echo 'No'; } elseif (false) { echo 'No'; } else { echo 'Yes'; }
  • 20. Switch <?php switch ('PHP') { case 'Ruby': echo 'No'; break; case 'PHP': echo 'Yes'; break; }
  • 21. Operators
  • 22. Arithmetic <?php $a = 10; $b = $a + 1; // 11 $c = $a - 1; // 9 $d = $a * 5; // 50 $e = $a / 2; // 5 $f = $a % 3; // 1
  • 23. String Concatenation <?php $myString = 'foo' . 'bar'; // foobar $myString .= 'baz'; // foobarbaz
  • 24. Comparison
  • 25. Equivalence <?php if (2 == 3) { echo 'No'; } if (3 == '3') { echo 'Yes'; } if (2 != 3) { echo 'Yes'; }
  • 26. Identity <?php if (3 === '3') { echo 'No'; } if (3 === 3) { echo 'Yes'; } if (3 !== 4) { echo 'Yes'; }
  • 27. Logical Operators <?php // NOT if (!true) { echo 'No'; } // AND if (true && false) { echo 'No'; } // OR if (true || false) { echo 'No'; }
  • 28. Strings & Interpolation
  • 29. Literal Single Quotes <?php $x = 2; echo 'I ate $x cookies.'; // I ate $x cookies.
  • 30. Double Quotes <?php $x = 2; echo "I ate $x cookies."; // I ate 2 cookies.
  • 31. Literal Double Quotes <?php $x = 2; echo "I ate $x cookies."; // I ate $x cookies.
  • 32. Curly Brace Double Quotes <?php $x = 2; echo "I ate {$x} cookies."; // I ate 2 cookies.
  • 33. Constants
  • 34. Defining <?php define('HELLO', 'Hello, Code Camp'); echo HELLO; // Hello, Code Camp
  • 35. As of PHP 5.3 <?php const HELLO = 'Hello, Code Camp'; echo HELLO; // Hello, Code Camp
  • 36. Arrays
  • 37. Enumerative
  • 38. Automatic Indexing <?php $foo[] = 'bar'; // [0] => bar $foo[] = 'baz'; // [1] => baz
  • 39. Explicit Indexing <?php $foo[0] = 'bar'; // [0] => bar $foo[1] = 'baz'; // [1] => baz
  • 40. Array Construct with Automatic Indexing <?php $foo = array( 'bar', // [0] => bar 'baz', // [1] => baz );
  • 41. Array Construct with Explicit Indexing <?php $foo = array( 0 => 'bar', // [0] => bar 1 => 'baz', // [1] => baz );
  • 42. Array Construct with Arbitrary Indexing <?php $foo = array( 1 => 'bar', // [1] => bar 2 => 'baz', // [2] => baz );
  • 43. Associative
  • 44. Explicit Indexing <?php $foo['a'] = 'bar'; // [a] => bar $foo['b'] = 'baz'; // [b] => baz
  • 45. Array Construct <?php $foo = array( 'a' => 'bar', // [a] => bar 'b' => 'baz', // [b] => baz );
  • 46. Iterators
  • 47. While <?php $x = 0; while ($x < 5) { echo '.'; $x++; }
  • 48. For <?php for ($x = 0; $x < 5; $x++) { echo '.'; }
  • 49. Foreach <?php $x = array(0, 1, 2, 3, 4); foreach ($x as $y) { echo $y; }
  • 50. Foreach Key/Value Pairs <?php $talks = array( 'php' => 'Intro to PHP', 'ruby' => 'Intro to Ruby', ); foreach ($talks as $id => $name) { echo "$name is talk ID $id."; echo PHP_EOL; }
  • 51. Functions
  • 52. Built-in <?php echo strlen('Hello'); // 5 echo trim(' Hello '); // Hello echo count(array(0, 1, 2, 3)); // 4 echo uniqid(); // 4c8a6660519d5 echo mt_rand(0, 9); // 3 echo serialize(42); // i:42; echo json_encode(array('a' => 'b')); // {"a":"b"}
  • 53. User-Defined <?php function add($x, $y) { return $x + $y; } echo add(2, 4); // 6
  • 54. Anonymous Functions / Closures (since PHP 5.3)
  • 55. Variable Assignment <?php $sayHi = function () { return 'Hi'; }; echo $sayHi(); // Hi
  • 56. Callbacks <?php $values = array(3, 7, 2); usort($values, function ($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; }); /* [0] => 2 [1] => 3 [2] => 7 */
  • 57. Classes & Objects
  • 58. Class Declaration <?php class Car { }
  • 59. Property Declaration <?php class Car { private $_hasSunroof = true; }
  • 60. Method Declaration <?php class Car { public function hasSunroof() { return $this->_hasSunroof; } }
  • 61. Class Constants <?php class Car { const ENGINE_V4 = 'V4'; const ENGINE_V6 = 'V6'; const ENGINE_V8 = 'V8'; } echo Car::ENGINE_V6; // V6
  • 62. Object Instantiation & Member Access <?php $myCar = new Car(); if ($myCar->hasSunroof()) { echo 'Yay!'; }
  • 63. Class Inheritance <?php class Chevy extends Car { }
  • 64. Interfaces <?php interface Vehicle { public function hasSunroof(); }
  • 65. Implementing Interfaces <?php class Car implements Vehicle { public function hasSunroof() { return $this->_hasSunroof; } }
  • 66. Member Visibility
  • 67. Public Default visibility Visible everywhere
  • 68. Protected Visible to child classes Visible to the object itself Visible to other objects of the same type
  • 69. Private Visible to the object itself Visible within the defining class declaration
  • 70. Tools
  • 71. IDEs Eclipse (PDT, Zend Studio, Aptana) NetBeans PHPStorm Emacs Vim Many more…
  • 72. Frameworks Zend Framework Symfony CodeIgniter Agavi CakePHP Many more…
  • 73. PEAR PHP Extension and Application Repository Package manager PECL (PHP Extension Community Library)
  • 74. Miscellaneous Tools PHPUnit phpDocumentor Phing PHP CodeSniffer PHP Mess Detector phpUnderControl
  • 75. Example PHP Scripts http://github.com/bradley-holt/introduction-to-php
  • 76. Questions?
  • 77. Thank You Bradley Holt (http://bradley-holt.com/) & Matthew Weier O’Phinney (http:/ /weierophinney.net/matthew/) Feedback: http://joind.in/1976