Using PHP

1,552 views
1,508 views

Published on

Peter Brown & Mark Casias talk about PHP and all the great things that go alon

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,552
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide



































































  • Using PHP

    1. 1. USING PHP Peter Brown Mark Casias brown.peterg@gmail.com markie@teampoop.com @litescript @teampoop
    2. 2. PHP IS... ...PHP: Hypertext Pre-processor is a scripting language used to add dynamic content to web pages.  ...embedded directly into your HTML code. ...a server-side scripting language, allowing the coder to ignore browser types/versions/specifications. ...extremely popular!
    3. 3. PHP IS... ...PHP: Hypertext Pre-processor is a scripting language used to add dynamic content to web pages.  ...embedded directly into your HTML code. ...a server-side scripting language, allowing the coder to ignore browser types/versions/specifications. ...extremely popular!
    4. 4. PHP ISN'T...
    5. 5. PHP ISN'T... ...a magic bullet.
    6. 6. PHP ISN'T... ...a magic bullet. ...necessary for every application.
    7. 7. PHP ISN'T... ...a magic bullet. ...necessary for every application. ...pure awesome bottled for your enjoyment after 1 year of conditioning...wait...
    8. 8. SOUNDS GREAT (IT IS) - WHAT DO I NEED?
    9. 9. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server.
    10. 10. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server.
    11. 11. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration.
    12. 12. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you.
    13. 13. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files.
    14. 14. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files. You can get as intense or simple as you want - check the online manual!
    15. 15. SOUNDS GREAT (IT IS) - WHAT DO I NEED? PHP installed and enabled on your server. PHP is open-source and free. Download and install it if not already installed on your server. Configuration. Usually done for you. PHP set to handle all .php files. You can get as intense or simple as you want - check the online manual! Dashing good looks; debonair attitude. 
    16. 16. WHERE DO I COME FROM?
    17. 17. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket.
    18. 18. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts.
    19. 19. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.
    20. 20. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.  Original name, "Personal Home Page Tools" - PHP Tools.
    21. 21. WHERE DO I COME FROM? Ask your parents, kid...that ain't my racket. PHP was originally a set of Perl scripts. Notice the Perl-like syntax, nerds.  Original name, "Personal Home Page Tools" - PHP Tools. Current PHP version (as of today): 5.3.3
    22. 22. YOUR FIRST PHP (subtext: ubiquitous "Hello, world!") <html>     <head>     <title>My First PHP page</title>     </head>     <body>         <?php             echo ("Bonjour, monde!");         ?>     </body> </html> 
    23. 23. WHAT JUST HAPPENED?
    24. 24. WHAT JUST HAPPENED? PHP is embedded directly into your HTML.
    25. 25. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <?
    26. 26. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?>
    27. 27. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ?
    28. 28. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)
    29. 29. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)  The rest is magic!
    30. 30. WHAT JUST HAPPENED? PHP is embedded directly into your HTML. Begin "PHP mode" using either <?php or <? exit "PHP mode" using ?> What's echo(); ? echo(); or more simply print(); prints to screen. (<?=$var?>)  The rest is magic! kidding...
    31. 31. LET'S DIVE IN
    32. 32. LET'S DIVE IN Functions:
    33. 33. LET'S DIVE IN Functions: Basic building blocks.
    34. 34. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();")
    35. 35. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here }
    36. 36. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here } To call your function: thename();
    37. 37. LET'S DIVE IN Functions: Basic building blocks. Create your own; use built in functions (eg, "echo();") Syntax: function thename($arg) {      // code to execute goes here } To call your function: thename(); Variables (super easy): $variablename;
    38. 38. FORMS
    39. 39. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form>
    40. 40. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy.
    41. 41. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down.
    42. 42. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name.
    43. 43. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name. eg: <?php $userid; $pass; ?>
    44. 44. FORMS Get some info! <form name="login" action="script.php" method=”post”>      <input type="text" name="userid" />      <input type="password" name="pass" /> </form> OK that's great...nice form buddy. First of all: calm down. This is useful! name="" is your variable name. eg: <?php $userid; $pass; ?> OOOOOORRRR you need a SUPER VARIABLE! $_REQUEST, $_POST, $_MOM
    45. 45. TIME TO DROWN
    46. 46.         TIME TO DROWN                                                                                            
    47. 47.         TIME TO DROWN                                                                         - What's going on here?!          - Baby, let me explain...            
    48. 48.         TIME TO DROWN                                                                                            
    49. 49. GET SOME CLASS
    50. 50. GET SOME CLASS Classes are PHP’s Objects
    51. 51. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions)
    52. 52. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables.
    53. 53. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class:
    54. 54. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo {
    55. 55. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’;
    56. 56. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’;
    57. 57. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) {
    58. 58. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’;
    59. 59. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; }
    60. 60. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; } }
    61. 61. GET SOME CLASS Classes are PHP’s Objects Contains variables and methods (functions) Private or Public methods/variables. Sample Class: class Foo { public $fighters = ‘good’; private $nirvana = ‘dead’; public breath($arg) { $this->nirvana=‘alive’; } }
    62. 62. DATABASE CONNECTABLES
    63. 63. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase
    64. 64. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database.
    65. 65. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor.
    66. 66. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor. It puts the lotion in the bucket.
    67. 67. DATABASE CONNECTABLES PHP Supports MOST database connections MySQL, Oracle (OCI8), Postgres, Sybase First, it connects to the database. Second, it makes it’s SQL query in the flavor. It puts the lotion in the bucket. Err I mean: a result set of information returns.
    68. 68. EXAMPLE
    69. 69. EXAMPLE
    70. 70. EXAMPLE <?php mysql_connect(localhost,$username,$password); $query = "SELECT * FROM SEWINGPLANS"; $bucket = mysql_query($query); mysql_close();
    71. 71. MORE DB FUN
    72. 72. MORE DB FUN Take the resource, and use it. <?php while($bucketArray = mysql_fetch_array($bucket)): echo “$bucketArray[‘skintype’]; endwhile;
    73. 73. MORE DB FUN Take the resource, and use it. <?php while($bucketArray = mysql_fetch_array($bucket)): echo “$bucketArray[‘skintype’]; endwhile; You could also make objects out of each row.
    74. 74. PHP PLATFORMS Yes, I am in fact, a broken record. Many out there in the world. Zend - Granddaddy of them. Many server solutions CakePHP - MCV implementation CodeIgniter - Better. And many many more
    75. 75. CODE IGNITER WIN Best documentation out of all Easiest Model... err.. model You don’t have to conform your data model to their will. Full MCV implementation. PHP Best Practices! http://codeigniter.com/user_guide/general/styleguide.html
    76. 76. CONFIGURATION View config with phpinfo(); php.ini file .htaccess files ini_set() function
    77. 77. TRULY SCARY!
    78. 78. TRULY SCARY!
    79. 79. TRULY SCARY! The End
    80. 80. TRULY SCARY!

    ×