SlideShare a Scribd company logo
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!
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
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).
<?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!
<?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!
<?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!
<?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!
<?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!
What does PHP mean?




http://en.wikipedia.org/wiki/PHP
What does PHP mean?
 Who cares?!?




http://en.wikipedia.org/wiki/PHP
What does PHP mean?
 Who cares?!?
 The question and answer that matter most are the




http://en.wikipedia.org/wiki/PHP
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
Diana’s Rule #1




Programming is asking the right questions and coming up with
possible answers.
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.
I’m a Mac.
Are you a Mac || a PC?



I’m a Mac.
Good Places to Start
Good Places to Start
• W3Schools Tutorial: http://www.w3schools.com/PHP/
Good Places to Start
• W3Schools Tutorial: http://www.w3schools.com/PHP/
• HeadFirst Labs Book: http://headfirstlabs.com/books/
hfphp/
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
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/
Diana’s Rule #2




How do I get to Carnegie Hall?
Diana’s Rule #2
 Write code.




How do I get to Carnegie Hall?
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?
Write Code!




I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
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
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
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
Write Code!




I recommend TextMate and Coda for Mac, EditPlus and Aptana for PCs
PHP for NonProgrammers (DrupalCon SF 2010)
<?php

/**
 * About Me
 */

$name = “Your Name Here”;

echo $name;

?>
Bonus point if you’ve seen the movie more than 5 times.
$name = “Trinity”;

Bonus point if you’ve seen the movie more than 5 times.
Diana’s Rule #3




“Stupid” mistakes are 85% of mistakes you’ll make.
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.
Four PHP Concepts
Four PHP Concepts
• Variables: containers for your stuff
Four PHP Concepts
• Variables: containers for your stuff
• Arrays: a variable that is a list, or a list of lists
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
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”
Variables
Variables
• begin with the ‘$’ symbol
Variables
• begin with the ‘$’ symbol
• should be aptly named
Variables
• begin with the ‘$’ symbol
• should be aptly named
• come in 8 different flavors
Variables
• begin with the ‘$’ symbol
• should be aptly named
• come in 8 different flavors
• are assigned a value using =
8 Types of Variables
8 Types of Variables
• Boolean: $fourKitchensWebChef = TRUE;
8 Types of Variables
• Boolean: $fourKitchensWebChef = TRUE;
• Integer: $numPets = 3;
8 Types of Variables
• Boolean: $fourKitchensWebChef = TRUE;
• Integer: $numPets = 3;
• Float: $pie = 3.1416;
8 Types of Variables
• Boolean: $fourKitchensWebChef = TRUE;
• Integer: $numPets = 3;
• Float: $pie = 3.1416;
• String: $hobbies = “I enjoy hiking.”;
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”);
And The Rest
And The Rest
Variables we won’t discuss (much) today:
And The Rest
Variables we won’t discuss (much) today:
• Object: $node->id
And The Rest
Variables we won’t discuss (much) today:
• Object: $node->id
• Resource: the database connection, for example
And The Rest
Variables we won’t discuss (much) today:
• Object: $node->id
• Resource: the database connection, for example
• NULL
1 point for the group name, 1 point each for individual
names
$montyPython = array(“TerryG”, “John”,
           “Michael”, “TerryJ”, “Eric”, “Graham”);

1 point for the group name, 1 point each for individual
names
Arrays




array keys start with 0
Arrays
 $myPets = array(“Maya”, “Cloe”, “August”);

 echo $myPets[0];




array keys start with 0
Maya



 Arrays
 $myPets = array(“Maya”, “Cloe”, “August”);

 echo $myPets[0];




array keys start with 0
Foreach is your friend
$myPets = array(“Maya”, “Cloe”, “August”);

foreach ($myPets as $pet) {
  echo $pet;
  echo “<br />”;
}
// $pet is a variable you create
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
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
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
<?php

 /**
  * About Me
  */

 $name = “Your Name Here”;


 $yourList = array(“Thing1”, “Thing2”, “Thing3”);

 ?>

Write your own version!
<?php

 /**
  * About Me                    add some
  */                             variables

 $name = “Your Name Here”;


 $yourList = array(“Thing1”, “Thing2”, “Thing3”);

 ?>

Write your own version!
<?php

 /**
  * About Me                             add some
  */                                      variables

 $name = “Your Name Here”;


 $yourList = array(“Thing1”, “Thing2”, “Thing3”);
                          add an array
 ?>

Write your own version!
TRUE || FALSE




Bonus point if you shout “Janeway!”
TRUE || FALSE




Bonus point if you shout “Janeway!”
TRUE || FALSE




Bonus point if you shout “Janeway!”
TRUE || FALSE




                                         TRUE



Bonus point if you shout “Janeway!”
Symbols to Know




More: http://www.w3schools.com/PHP/php_operators.asp
Symbols to Know
 • Assignment: =




More: http://www.w3schools.com/PHP/php_operators.asp
Symbols to Know
 • Assignment: =
 • AND: &&




More: http://www.w3schools.com/PHP/php_operators.asp
Symbols to Know
 • Assignment: =
 • AND: &&
 • OR: ||



More: http://www.w3schools.com/PHP/php_operators.asp
Symbols to Know
 • Assignment: =
 • AND: &&
 • OR: ||
 • Greater and Less Than: > <


More: http://www.w3schools.com/PHP/php_operators.asp
Symbols to Know
 • Assignment: =
 • AND: &&
 • OR: ||
 • Greater and Less Than: > <
 • Is Equal To: ==

More: http://www.w3schools.com/PHP/php_operators.asp
Let’s Talk Boolean
Let’s Talk Boolean
• My name is Diana
Let’s Talk Boolean
• My name is Diana
• My name is Diana && I own a motorcycle
Let’s Talk Boolean
• My name is Diana
• My name is Diana && I own a motorcycle
• My name Diana || I am younger than 29
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
PHP for NonProgrammers (DrupalCon SF 2010)
$myMotorcycle = “BMW F650GS”;
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.”;
}
<?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: }
<?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: }
<?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: }
<?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!
<?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!
<?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!
A bonus point if you’ve read the book && seen the movie
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
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
// 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;
  }
}
// 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;
  }
}
// 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;
  }
}
// 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;
  }
}
Function Facts
Function Facts
• include the word “function”
Function Facts
• include the word “function”
• should be aptly named
Function Facts
• include the word “function”
• should be aptly named
• can accept one or more parameters
Function Facts
• include the word “function”
• should be aptly named
• can accept one or more parameters
• can return something
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
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
<?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!
<?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!
<?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!
<?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!
<?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!
<?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!
<?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!
What does he do for a living?




Score one point for each title you can name
Diana’s Rule #4




Practice makes a programmer.
Diana’s Rule #4
 Read and dissect (good) code.




Practice makes a programmer.
Diana’s Rule #5




http://drupal.org/node/287350
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
Browser Points




Modern Browsers Only!
Browser Points
 • +10: Firefox && (Chrome || Opera)




Modern Browsers Only!
Browser Points
 • +10: Firefox && (Chrome || Opera)
 • +8: Firefox && (IE 7 || IE 8 || Safari)




Modern Browsers Only!
Browser Points
 • +10: Firefox && (Chrome || Opera)
 • +8: Firefox && (IE 7 || IE 8 || Safari)
 • +5: Firefox




Modern Browsers Only!
Browser Points
 • +10: Firefox && (Chrome || Opera)
 • +8: Firefox && (IE 7 || IE 8 || Safari)
 • +5: Firefox
 • +3: IE 7 || IE 8




Modern Browsers Only!
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!
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!
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
Take the Survey
http://sf2010.drupal.org/conference/schedule

More Related Content

What's hot (10)

KEY
Ruby
Kerry Buckley
 
PDF
Ruby on Rails Presentation
adamcookeuk
 
PPT
Django O/R Mapper
Ian Lewis
 
PPT
Best practices in museum search
Nate Solas
 
KEY
Code Fast, Die Young, Throw Structured Exceptions
John Anderson
 
PDF
Cowboy development with Django
Simon Willison
 
PDF
You Don't Know Query - WordCamp Portland 2011
andrewnacin
 
PPT
Mashup University 4: Intro To Mashups
John Herren
 
PDF
Task 1
EdiPHP
 
PDF
Building Things Fast - and getting approval
Simon Willison
 
Ruby on Rails Presentation
adamcookeuk
 
Django O/R Mapper
Ian Lewis
 
Best practices in museum search
Nate Solas
 
Code Fast, Die Young, Throw Structured Exceptions
John Anderson
 
Cowboy development with Django
Simon Willison
 
You Don't Know Query - WordCamp Portland 2011
andrewnacin
 
Mashup University 4: Intro To Mashups
John Herren
 
Task 1
EdiPHP
 
Building Things Fast - and getting approval
Simon Willison
 

Viewers also liked (20)

PDF
Don't Design Websites. Design Web SYSTEMS! (DrupalCon Chicago 2011)
Four Kitchens
 
KEY
Intro to Drush
Four Kitchens
 
PDF
Big Websites for Small Screens: ICANN.org Case Study
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (DrupalCamp LA 2011)
Four Kitchens
 
KEY
Teaching Drupal
Four Kitchens
 
PPT
Clase parker
Carlos Muñoz
 
PDF
Four Kitchens: We make BIG websites
Four Kitchens
 
PDF
Scalable Drupal infrastructure
Four Kitchens
 
PDF
Foucault%20y%20 senett[1]
Carlos Muñoz
 
PPT
Horswell x maría josé villanueva
Carlos Muñoz
 
PDF
9. Bell
Carlos Muñoz
 
KEY
Big Websites
Four Kitchens
 
PDF
Is Drupal secure?
Four Kitchens
 
PDF
3 zizek multiculturalismo o la lógica cultural del capitalismo multinacional
Carlos Muñoz
 
PDF
Accelerated grid theming using NineSixty (DrupalCamp Dallas)
Four Kitchens
 
PDF
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2009)
Four Kitchens
 
PDF
UX design for every screen
Four Kitchens
 
PDF
Four Kitchens Presents: Future of the CMS
Four Kitchens
 
PDF
PowerPoint et mon cours - 5 règles pour une présentation efficace
GROLLEAU Anne-Céline
 
PDF
Les réseaux sociaux dans votre stratégie de contenu en 10 questions
Kiss The Bride
 
Don't Design Websites. Design Web SYSTEMS! (DrupalCon Chicago 2011)
Four Kitchens
 
Intro to Drush
Four Kitchens
 
Big Websites for Small Screens: ICANN.org Case Study
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (DrupalCamp LA 2011)
Four Kitchens
 
Teaching Drupal
Four Kitchens
 
Clase parker
Carlos Muñoz
 
Four Kitchens: We make BIG websites
Four Kitchens
 
Scalable Drupal infrastructure
Four Kitchens
 
Foucault%20y%20 senett[1]
Carlos Muñoz
 
Horswell x maría josé villanueva
Carlos Muñoz
 
9. Bell
Carlos Muñoz
 
Big Websites
Four Kitchens
 
Is Drupal secure?
Four Kitchens
 
3 zizek multiculturalismo o la lógica cultural del capitalismo multinacional
Carlos Muñoz
 
Accelerated grid theming using NineSixty (DrupalCamp Dallas)
Four Kitchens
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2009)
Four Kitchens
 
UX design for every screen
Four Kitchens
 
Four Kitchens Presents: Future of the CMS
Four Kitchens
 
PowerPoint et mon cours - 5 règles pour une présentation efficace
GROLLEAU Anne-Céline
 
Les réseaux sociaux dans votre stratégie de contenu en 10 questions
Kiss The Bride
 
Ad

Similar to PHP for NonProgrammers (DrupalCon SF 2010) (20)

PDF
Zend Certification Preparation Tutorial
Lorna Mitchell
 
PPT
Php(report)
Yhannah
 
PPT
php 1
tumetr1
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PPTX
Day1
IRWAA LLC
 
PDF
Lecture14-Introduction to PHP-coding.pdf
IotenergyWater
 
PDF
phptutorial
tutorialsruby
 
PDF
PHP Basics Ebook
Swanand Pol
 
PDF
phptutorial
tutorialsruby
 
PDF
Introduction to php
KIRAN KUMAR SILIVERI
 
PPTX
Php basics
Jamshid Hashimi
 
PPTX
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
PPT
Php mysql
Alebachew Zewdu
 
PPT
Php training100%placement-in-mumbai
vibrantuser
 
PPT
Overview of php
Tabeer12
 
PPTX
Ch1(introduction to php)
Chhom Karath
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPTX
Php Unit 1
team11vgnt
 
PPTX
Introduction to-php
AhmedAElHalimAhmed
 
PPT
PHP - Web Development
Niladri Karmakar
 
Zend Certification Preparation Tutorial
Lorna Mitchell
 
Php(report)
Yhannah
 
php 1
tumetr1
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Day1
IRWAA LLC
 
Lecture14-Introduction to PHP-coding.pdf
IotenergyWater
 
phptutorial
tutorialsruby
 
PHP Basics Ebook
Swanand Pol
 
phptutorial
tutorialsruby
 
Introduction to php
KIRAN KUMAR SILIVERI
 
Php basics
Jamshid Hashimi
 
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
Php mysql
Alebachew Zewdu
 
Php training100%placement-in-mumbai
vibrantuser
 
Overview of php
Tabeer12
 
Ch1(introduction to php)
Chhom Karath
 
introduction to php and its uses in daily
vishal choudhary
 
Php Unit 1
team11vgnt
 
Introduction to-php
AhmedAElHalimAhmed
 
PHP - Web Development
Niladri Karmakar
 
Ad

More from Four Kitchens (19)

PDF
Don't Design Websites. Design Web SYSTEMS! (UT Austin Drupal Users Group)
Four Kitchens
 
PDF
No RFPs! Why requests for proposal are bad for business (and how we can stop ...
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (BADCamp 2011)
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (DrupalCon London 2011)
Four Kitchens
 
PDF
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (Dallas Drupal Days 2011)
Four Kitchens
 
KEY
Building Responsive Websites and Apps with Drupal
Four Kitchens
 
PDF
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Four Kitchens
 
KEY
Designing future proof websites
Four Kitchens
 
PDF
Making drupal beautiful with web fonts
Four Kitchens
 
PDF
The type revolutionary's cookbook
Four Kitchens
 
PDF
The Web Chef Cookbook
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (DrupalCamp Stockholm 2011)
Four Kitchens
 
PDF
Don't Design Websites. Design Web SYSTEMS! (DrupalCon Copenhagen 2010)
Four Kitchens
 
KEY
The state of web typography
Four Kitchens
 
PDF
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Four Kitchens
 
PDF
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
Four Kitchens
 
PDF
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Four Kitchens
 
PDF
Drupal theming using the 960.gs grid system
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (UT Austin Drupal Users Group)
Four Kitchens
 
No RFPs! Why requests for proposal are bad for business (and how we can stop ...
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (BADCamp 2011)
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (DrupalCon London 2011)
Four Kitchens
 
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (Dallas Drupal Days 2011)
Four Kitchens
 
Building Responsive Websites and Apps with Drupal
Four Kitchens
 
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Four Kitchens
 
Designing future proof websites
Four Kitchens
 
Making drupal beautiful with web fonts
Four Kitchens
 
The type revolutionary's cookbook
Four Kitchens
 
The Web Chef Cookbook
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (DrupalCamp Stockholm 2011)
Four Kitchens
 
Don't Design Websites. Design Web SYSTEMS! (DrupalCon Copenhagen 2010)
Four Kitchens
 
The state of web typography
Four Kitchens
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Four Kitchens
 
From Photoshop to Drupal Theme (DrupalCon San Francisco 2010)
Four Kitchens
 
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Four Kitchens
 
Drupal theming using the 960.gs grid system
Four Kitchens
 

Recently uploaded (20)

PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

PHP for NonProgrammers (DrupalCon SF 2010)

  • 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.
  • 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
  • 31. <?php /** * About Me */ $name = “Your Name Here”; echo $name; ?>
  • 32. Bonus point if you’ve seen the movie more than 5 times.
  • 33. $name = “Trinity”; Bonus point if you’ve seen the movie more than 5 times.
  • 34. Diana’s Rule #3 “Stupid” mistakes are 85% of mistakes you’ll make.
  • 35. 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.
  • 37. Four PHP Concepts • Variables: containers for your stuff
  • 38. Four PHP Concepts • Variables: containers for your stuff • Arrays: a variable that is a list, or a list of lists
  • 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
  • 40. 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”
  • 42. Variables • begin with the ‘$’ symbol
  • 43. Variables • begin with the ‘$’ symbol • should be aptly named
  • 44. Variables • begin with the ‘$’ symbol • should be aptly named • come in 8 different flavors
  • 45. Variables • begin with the ‘$’ symbol • should be aptly named • come in 8 different flavors • are assigned a value using =
  • 46. 8 Types of Variables
  • 47. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE;
  • 48. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3;
  • 49. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3; • Float: $pie = 3.1416;
  • 50. 8 Types of Variables • Boolean: $fourKitchensWebChef = TRUE; • Integer: $numPets = 3; • Float: $pie = 3.1416; • String: $hobbies = “I enjoy hiking.”;
  • 51. 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”);
  • 53. And The Rest Variables we won’t discuss (much) today:
  • 54. And The Rest Variables we won’t discuss (much) today: • Object: $node->id
  • 55. And The Rest Variables we won’t discuss (much) today: • Object: $node->id • Resource: the database connection, for example
  • 56. And The Rest Variables we won’t discuss (much) today: • Object: $node->id • Resource: the database connection, for example • NULL
  • 57. 1 point for the group name, 1 point each for individual names
  • 58. $montyPython = array(“TerryG”, “John”, “Michael”, “TerryJ”, “Eric”, “Graham”); 1 point for the group name, 1 point each for individual names
  • 60. Arrays $myPets = array(“Maya”, “Cloe”, “August”); echo $myPets[0]; array keys start with 0
  • 61. Maya Arrays $myPets = array(“Maya”, “Cloe”, “August”); echo $myPets[0]; array keys start with 0
  • 62. Foreach is your friend $myPets = array(“Maya”, “Cloe”, “August”); foreach ($myPets as $pet) { echo $pet; echo “<br />”; } // $pet is a variable you create
  • 63. 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
  • 64. 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. 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
  • 66. <?php /** * About Me */ $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”); ?> Write your own version!
  • 68. <?php /** * About Me add some */ variables $name = “Your Name Here”; $yourList = array(“Thing1”, “Thing2”, “Thing3”); add an array ?> Write your own version!
  • 69. TRUE || FALSE Bonus point if you shout “Janeway!”
  • 70. TRUE || FALSE Bonus point if you shout “Janeway!”
  • 71. TRUE || FALSE Bonus point if you shout “Janeway!”
  • 72. TRUE || FALSE TRUE Bonus point if you shout “Janeway!”
  • 73. Symbols to Know More: http://www.w3schools.com/PHP/php_operators.asp
  • 74. Symbols to Know • Assignment: = More: http://www.w3schools.com/PHP/php_operators.asp
  • 75. Symbols to Know • Assignment: = • AND: && More: http://www.w3schools.com/PHP/php_operators.asp
  • 76. Symbols to Know • Assignment: = • AND: && • OR: || More: http://www.w3schools.com/PHP/php_operators.asp
  • 77. Symbols to Know • Assignment: = • AND: && • OR: || • Greater and Less Than: > < More: http://www.w3schools.com/PHP/php_operators.asp
  • 78. Symbols to Know • Assignment: = • AND: && • OR: || • Greater and Less Than: > < • Is Equal To: == More: http://www.w3schools.com/PHP/php_operators.asp
  • 80. Let’s Talk Boolean • My name is Diana
  • 81. Let’s Talk Boolean • My name is Diana • My name is Diana && I own a motorcycle
  • 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
  • 83. 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
  • 86. 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.”; }
  • 87. <?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: }
  • 88. <?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: }
  • 89. <?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: }
  • 90. <?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!
  • 91. <?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!
  • 92. <?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!
  • 93. A bonus point if you’ve read the book && seen the movie
  • 94. 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
  • 95. 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
  • 96. // 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; } }
  • 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.”; } /** * Returns true if number of fingers is 6 */ function isSixFingeredMan($numFingers) { if ($numFingers == 6) { return TRUE; } else { return FALSE; } }
  • 98. // 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; } }
  • 99. // 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; } }
  • 101. Function Facts • include the word “function”
  • 102. Function Facts • include the word “function” • should be aptly named
  • 103. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters
  • 104. Function Facts • include the word “function” • should be aptly named • can accept one or more parameters • can return something
  • 105. 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
  • 106. 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
  • 107. <?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!
  • 108. <?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!
  • 109. <?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!
  • 110. <?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!
  • 111. <?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!
  • 112. <?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!
  • 113. <?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!
  • 114. What does he do for a living? Score one point for each title you can name
  • 115. Diana’s Rule #4 Practice makes a programmer.
  • 116. Diana’s Rule #4 Read and dissect (good) code. Practice makes a programmer.
  • 118. 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
  • 120. Browser Points • +10: Firefox && (Chrome || Opera) Modern Browsers Only!
  • 121. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) Modern Browsers Only!
  • 122. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox Modern Browsers Only!
  • 123. Browser Points • +10: Firefox && (Chrome || Opera) • +8: Firefox && (IE 7 || IE 8 || Safari) • +5: Firefox • +3: IE 7 || IE 8 Modern Browsers Only!
  • 124. 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!
  • 125. 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!
  • 126. 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. [email protected]