Your SlideShare is downloading. ×
0
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
PHP for NonProgrammers (DrupalCon SF 2010)
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 for NonProgrammers (DrupalCon SF 2010)

4,471

Published on

Session offered at DrupalCon San Francisco 2010. "Physics for Poets" introduction to PHP concepts like variables, arrays, conditionals, and functions.

Session offered at DrupalCon San Francisco 2010. "Physics for Poets" introduction to PHP concepts like variables, arrays, conditionals, and functions.

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

No Downloads
Views
Total Views
4,471
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
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. Today’s Tools Write code: http://www.codepad.com Select PHP as the language! Ask questions: IRC: irc.freenode.net #php4np Twitter: php4np Robert Ristroph is here for you!
    • 2. PHP For NonProgrammers Programmer: One who writes computer programs. NonProgrammer: One who will write PHP code today while learning Diana’s Five Rules of Programming and earning geek points. DrupalCon San Francisco 2010
    • 3. You Win! Score more than 5 points during today’s presentation and win the Grand Prize Geek Award* (GPGA). * Four Kitchens’ stickers and the right to change your Facebook language to English(Pirate).
    • 4. <?php /** * About Me */ // also comments $name = “Diana Montalion Dupuis”; $fourKitchensWebChef = TRUE; $numPets = 3; $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”); if ($notWorking == TRUE) { echo “I’m reading a book or watching football.”; } else { echo “I’m writing PHP code.”; } ?> Write your own version!
    • 5. <?php /** comments * About Me */ // also comments $name = “Diana Montalion Dupuis”; $fourKitchensWebChef = TRUE; $numPets = 3; $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”); if ($notWorking == TRUE) { echo “I’m reading a book or watching football.”; } else { echo “I’m writing PHP code.”; } ?> Write your own version!
    • 6. <?php /** comments * About Me */ // also comments $name = “Diana Montalion Dupuis”; $fourKitchensWebChef = TRUE; variables $numPets = 3; $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”); if ($notWorking == TRUE) { echo “I’m reading a book or watching football.”; } else { echo “I’m writing PHP code.”; } ?> Write your own version!
    • 7. <?php /** comments * About Me */ // also comments $name = “Diana Montalion Dupuis”; $fourKitchensWebChef = TRUE; variables $numPets = 3; $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”); if ($notWorking == TRUE) { array echo “I’m reading a book or watching football.”; } else { echo “I’m writing PHP code.”; } ?> Write your own version!
    • 8. <?php /** comments * About Me */ // also comments $name = “Diana Montalion Dupuis”; $fourKitchensWebChef = TRUE; variables $numPets = 3; $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”); if ($notWorking == TRUE) { array echo “I’m reading a book or watching football.”; } else { echo “I’m writing PHP code.”; conditional } ?> Write your own version!
    • 9. What does PHP mean? http://en.wikipedia.org/wiki/PHP
    • 10. What does PHP mean? Who cares?!? http://en.wikipedia.org/wiki/PHP
    • 11. What does PHP mean? Who cares?!? The question and answer that matter most are the http://en.wikipedia.org/wiki/PHP
    • 12. What does PHP mean? Who cares?!? The question and answer that matter most are the PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. As a general-purpose programming language, PHP code is processed by an interpreter application in command line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as a standalone interpreter on most operating systems and computing platforms. http://en.wikipedia.org/wiki/PHP
    • 13. Diana’s Rule #1 Programming is asking the right questions and coming up with possible answers.
    • 14. Diana’s Rule #1 Self educate constantly. Your sixth-grade English teacher was right - if you don’t know, look it up. Find places to get help. Ignore whatever (or whomever) isn’t helpful. Programming is asking the right questions and coming up with possible answers.
    • 15. I’m a Mac.
    • 16. Are you a Mac || a PC? I’m a Mac.
    • 17. Good Places to Start
    • 18. Good Places to Start • W3Schools Tutorial: http://www.w3schools.com/PHP/
    • 19. Good Places to Start • W3Schools Tutorial: http://www.w3schools.com/PHP/ • HeadFirst Labs Book: http://headfirstlabs.com/books/ hfphp/
    • 20. Good Places to Start • W3Schools Tutorial: http://www.w3schools.com/PHP/ • HeadFirst Labs Book: http://headfirstlabs.com/books/ hfphp/ • PHP.net (and tutorial): http://php.net/manual/en/ tutorial.php
    • 21. Good Places to Start • W3Schools Tutorial: http://www.w3schools.com/PHP/ • HeadFirst Labs Book: http://headfirstlabs.com/books/ hfphp/ • PHP.net (and tutorial): http://php.net/manual/en/ tutorial.php • Pro Drupal Development Book: http:// www.drupalbook.com/
    • 22. Diana’s Rule #2 How do I get to Carnegie Hall?
    • 23. Diana’s Rule #2 Write code. How do I get to Carnegie Hall?
    • 24. Diana’s Rule #2 Write code. Writing code is the only thing that teaches you how to write code. How do I get to Carnegie Hall?
    • 25. Write Code! I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
    • 26. Write Code! 1. Use Codepad or open Notepad (or any other simple text program). I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
    • 27. Write Code! 1. Use Codepad or open Notepad (or any other simple text program). 2. Not Microsoft Word, never ever ever use Word. A piece of paper and a pen is fine too. I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
    • 28. Write Code! 1. Use Codepad or open Notepad (or any other simple text program). 2. Not Microsoft Word, never ever ever use Word. A piece of paper and a pen is fine too. 2. Write this in the top left-hand corner: I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
    • 29. Write Code! I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
    • 30. <?php /** * About Me */ $name = “Your Name Here”; echo $name; ?>
    • 31. Bonus point if you’ve seen the movie more than 5 times.
    • 32. $name = “Trinity”; Bonus point if you’ve seen the movie more than 5 times.
    • 33. Diana’s Rule #3 “Stupid” mistakes are 85% of mistakes you’ll make.
    • 34. Diana’s Rule #3 You will suffer daily from the Missing Semicolon Syndrome (MSS). Forgetting the semicolon is the most common syntax error. PHP errors will break your site. Don’t panic! Just fix them. “Stupid” mistakes are 85% of mistakes you’ll make.
    • 35. Four PHP Concepts
    • 36. Four PHP Concepts • Variables: containers for your stuff
    • 37. Four PHP Concepts • Variables: containers for your stuff • Arrays: a variable that is a list, or a list of lists
    • 38. Four PHP Concepts • Variables: containers for your stuff • Arrays: a variable that is a list, or a list of lists • Conditionals: the brains of your operation
    • 39. Four PHP Concepts • Variables: containers for your stuff • Arrays: a variable that is a list, or a list of lists • Conditionals: the brains of your operation • Functions: little blocks of “do stuff”
    • 40. Variables
    • 41. Variables • begin with the ‘$’ symbol
    • 42. Variables • begin with the ‘$’ symbol • should be aptly named
    • 43. Variables • begin with the ‘$’ symbol • should be aptly named • come in 8 different flavors
    • 44. Variables • begin with the ‘$’ symbol • should be aptly named • come in 8 different flavors • are assigned a value using =
    • 45. 8 Types of Variables
    • 46. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE;
    • 47. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3;
    • 48. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3; • Float: $pie = 3.1416;
    • 49. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3; • Float: $pie = 3.1416; • String: $hobbies = “I enjoy hiking.”;
    • 50. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3; • Float: $pie = 3.1416; • String: $hobbies = “I enjoy hiking.”; • Array: $currBooks = array(“The World Without Us”, “Outliers”, “Brain Rules”, “Wolf Hall”);
    • 51. And The Rest
    • 52. And The Rest Variables we won’t discuss (much) today:
    • 53. And The Rest Variables we won’t discuss (much) today: • Object: $node->id
    • 54. And The Rest Variables we won’t discuss (much) today: • Object: $node->id • Resource: the database connection, for example
    • 55. And The Rest Variables we won’t discuss (much) today: • Object: $node->id • Resource: the database connection, for example • NULL
    • 56. 1 point for the group name, 1 point each for individual names
    • 57. $montyPython = array(“TerryG”, “John”, “Michael”, “TerryJ”, “Eric”, “Graham”); 1 point for the group name, 1 point each for individual names
    • 58. Arrays array keys start with 0
    • 59. Arrays $myPets = array(“Maya”, “Cloe”, “August”); echo $myPets[0]; array keys start with 0
    • 60. Maya Arrays $myPets = array(“Maya”, “Cloe”, “August”); echo $myPets[0]; array keys start with 0
    • 61. Foreach is your friend $myPets = array(“Maya”, “Cloe”, “August”); foreach ($myPets as $pet) { echo $pet; echo “<br />”; } // $pet is a variable you create
    • 62. Maya Cloe August Foreach is your friend $myPets = array(“Maya”, “Cloe”, “August”); foreach ($myPets as $pet) { echo $pet; echo “<br />”; } // $pet is a variable you create
    • 63. Keys and Values $actor = array( ‘name’ => “John Cleese”, ‘nickname’ => “Bruce”, ‘job’ => “Minister of Silly Walks”, ); echo $actor[‘nickname’]; this is very common in Drupal coding
    • 64. Bruce Keys and Values $actor = array( ‘name’ => “John Cleese”, ‘nickname’ => “Bruce”, ‘job’ => “Minister of Silly Walks”, ); echo $actor[‘nickname’]; this is very common in Drupal coding
    • 65. <?php /** * About Me */ $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); ?> Write your own version!
    • 66. <?php /** * About Me add some */ variables $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); ?> Write your own version!
    • 67. <?php /** * About Me add some */ variables $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); add an array ?> Write your own version!
    • 68. TRUE || FALSE Bonus point if you shout “Janeway!”
    • 69. TRUE || FALSE Bonus point if you shout “Janeway!”
    • 70. TRUE || FALSE Bonus point if you shout “Janeway!”
    • 71. TRUE || FALSE TRUE Bonus point if you shout “Janeway!”
    • 72. Symbols to Know More: http://www.w3schools.com/PHP/php_operators.asp
    • 73. Symbols to Know • Assignment: = More: http://www.w3schools.com/PHP/php_operators.asp
    • 74. Symbols to Know • Assignment: = • AND: && More: http://www.w3schools.com/PHP/php_operators.asp
    • 75. Symbols to Know • Assignment: = • AND: && • OR: || More: http://www.w3schools.com/PHP/php_operators.asp
    • 76. Symbols to Know • Assignment: = • AND: && • OR: || • Greater and Less Than: > < More: http://www.w3schools.com/PHP/php_operators.asp
    • 77. Symbols to Know • Assignment: = • AND: && • OR: || • Greater and Less Than: > < • Is Equal To: == More: http://www.w3schools.com/PHP/php_operators.asp
    • 78. Let’s Talk Boolean
    • 79. Let’s Talk Boolean • My name is Diana
    • 80. Let’s Talk Boolean • My name is Diana • My name is Diana && I own a motorcycle
    • 81. Let’s Talk Boolean • My name is Diana • My name is Diana && I own a motorcycle • My name Diana || I am younger than 29
    • 82. Let’s Talk Boolean • My name is Diana • My name is Diana && I own a motorcycle • My name Diana || I am younger than 29 • (My name is Diana || I am younger than 29) && I own a motorcycle
    • 83. $myMotorcycle = “BMW F650GS”;
    • 84. Conditionals are Control if ($captain == “Picard”) { echo “Make it so, Number One.”; } elseif ($captain == “Kirk”) { echo “Two to beam up.”; } else { echo “Please state the nature of your medical emergency.”; }
    • 85. <?php /** * Boolean Example */ $captain = “Janeway”; if ($captain == “Picard”) { echo “Make it so, Number One.”; } elseif ($captain == “Kirk”) { echo “Two to beam up.”; } else { echo “Please state the nature of your medical emergency.”; ?> There is an MSS issue in this code, can you find it? Hint: }
    • 86. <?php Please state the nature of your medical emergency. /** * Boolean Example */ $captain = “Janeway”; if ($captain == “Picard”) { echo “Make it so, Number One.”; } elseif ($captain == “Kirk”) { echo “Two to beam up.”; } else { echo “Please state the nature of your medical emergency.”; ?> There is an MSS issue in this code, can you find it? Hint: }
    • 87. <?php Please state the nature of your medical emergency. /** * Boolean Example */ $captain = “Janeway”; MSS ALERT! if ($captain == “Picard”) { echo “Make it so, Number One.”; } elseif ($captain == “Kirk”) { echo “Two to beam up.”; } else { echo “Please state the nature of your medical emergency.”; ?> There is an MSS issue in this code, can you find it? Hint: }
    • 88. <?php /** * About Me */ $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); if (variable == something && variable == something) { print “A clever sentence”; } ?> Write your own version!
    • 89. <?php /** * About Me */ variables $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); if (variable == something && variable == something) { print “A clever sentence”; } ?> Write your own version!
    • 90. <?php /** * About Me */ variables $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); if (variable == something && variable == something) { print “A clever sentence”; } add a conditional ?> Write your own version!
    • 91. A bonus point if you’ve read the book && seen the movie
    • 92. Hello. My name is Inigo Montoya. You killed my father. Prepare to die. A bonus point if you’ve read the book && seen the movie
    • 93. Functions Functions encapsulate code that does a specific task. The function can be called whenever the task needs to be performed. Tutorial: http://www.tizag.com/phpT/phpfunctions.php
    • 94. // call the function to count the fingers $killHim = isSixFingeredMan($numFingers); if ($killHim) { echo “Hello. My name is Inigo Montoya. You killed my father. Prepare to die.”; } /** * Returns true if number of fingers is 6 */ function isSixFingeredMan($numFingers) { if ($numFingers == 6) { return TRUE; } else { return FALSE; } }
    • 95. // call the function to count the fingers $killHim = isSixFingeredMan($numFingers); call if ($killHim) { echo “Hello. My name is Inigo Montoya. You killed my father. Prepare to die.”; } /** * Returns true if number of fingers is 6 */ function isSixFingeredMan($numFingers) { if ($numFingers == 6) { return TRUE; } else { return FALSE; } }
    • 96. // call the function to count the fingers $killHim = isSixFingeredMan($numFingers); call if ($killHim) { echo “Hello. My name is Inigo Montoya. You killed my father. Prepare to die.”; } /** * Returns true if number of fingers is 6 */ function isSixFingeredMan($numFingers) { if ($numFingers == 6) { return TRUE; } else { function return FALSE; } }
    • 97. // call the function to count the fingers $killHim = isSixFingeredMan($numFingers); call if ($killHim) { echo “Hello. My name is Inigo Montoya. You killed my father. Prepare to die.”; } continue on /** * Returns true if number of fingers is 6 */ function isSixFingeredMan($numFingers) { if ($numFingers == 6) { return TRUE; } else { function return FALSE; } }
    • 98. Function Facts
    • 99. Function Facts • include the word “function”
    • 100. Function Facts • include the word “function” • should be aptly named
    • 101. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters
    • 102. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters • can return something
    • 103. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters • can return something • should be used for repeated tasks and to organize logic
    • 104. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters • can return something • should be used for repeated tasks and to organize logic • can be public or private
    • 105. <?php /** * Function Fun */ $yourVariable = “Something”; $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } ?> Write your own version!
    • 106. <?php /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } ?> Write your own version!
    • 107. <?php /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; call your function public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } ?> Write your own version!
    • 108. <?php /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; call your function public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } add a function ?> Write your own version!
    • 109. <?php /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } add a function ?> Write your own version!
    • 110. <?php /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; continue on public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } add a function ?> Write your own version!
    • 111. <?php Here’s a sentence containing Something. /** * Function Fun */ $yourVariable = “Something”; define a variable $returnedVariable = NULL; $returnedVariable = yourFunction($yourVariable); echo $returnedVariable; continue on public function yourFunction($yourVariable) { $greeting = “Here’s a sentence containing “. $yourVariable; return $greeting; } add a function ?> Write your own version!
    • 112. What does he do for a living? Score one point for each title you can name
    • 113. Diana’s Rule #4 Practice makes a programmer.
    • 114. Diana’s Rule #4 Read and dissect (good) code. Practice makes a programmer.
    • 115. Diana’s Rule #5 http://drupal.org/node/287350
    • 116. Diana’s Rule #5 Follow best practices. Like the rules of the road, best practices prevent (coding) accidents. They also make you a likable person. http://drupal.org/node/287350
    • 117. Browser Points Modern Browsers Only!
    • 118. Browser Points • +10: Firefox && (Chrome || Opera) Modern Browsers Only!
    • 119. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) Modern Browsers Only!
    • 120. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox Modern Browsers Only!
    • 121. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox • +3: IE 7 || IE 8 Modern Browsers Only!
    • 122. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox • +3: IE 7 || IE 8 • +1: Safari Modern Browsers Only!
    • 123. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox • +3: IE 7 || IE 8 • +1: Safari • -3,890,745: IE 6 Modern Browsers Only!
    • 124. Diana’s Five Rules 1. Constantly self educate. 2. Write code. 3. Accept Missing Semicolon Syndrome gracefully. 4. Read and dissect (good) code. 5. Follow best practices. diana@fourkitchens.com
    • 125. Take the Survey http://sf2010.drupal.org/conference/schedule

    ×