Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP For Absolute Beginners

PHP For Absolute Beginners

Talk given at the Winnipeg WordPress Meetup on March 6, 2013.

Matt Wiebe

March 06, 2013
Tweet

More Decks by Matt Wiebe

Other Decks in Programming

Transcript

  1. PHP

  2. PHP

  3. What is PHP? ★ The thing that makes WordPress work

    ★ The thing you should know a little bit about if you want to tweak a theme or plugin.
  4. What is PHP? ★ The thing that makes WordPress work

    ★ The thing you should know a little bit about if you want to tweak a theme or plugin. ★ PHP: Hypertext Preprocessor
  5. What is PHP? ★ The thing that makes WordPress work

    ★ The thing you should know a little bit about if you want to tweak a theme or plugin. ★ PHP: Hypertext Preprocessor ★ The easiest way to get started with programming.
  6. What is PHP? ★ The thing that makes WordPress work

    ★ The thing you should know a little bit about if you want to tweak a theme or plugin. ★ PHP: Hypertext Preprocessor ★ The easiest way to get started with programming. (except maybe JavaScript)
  7. Why should I learn PHP? ★ It’s what makes WordPress

    sing and dance ★ It’s easy ★ It’s fun
  8. Why should I learn PHP? ★ It’s what makes WordPress

    sing and dance ★ It’s easy ★ It’s fun ★ It might turn a hobby into a career
  9. Variables $my_string = 'bar'; // This is a comment. It

    is ignored. $my_number = 3; $my_array = array('one', 'two', 'ten');
  10. Variables $my_string = 'bar'; // This is a comment. It

    is ignored. $my_number = 3; $my_array = array('one', 'two', 'ten'); $my_boolean = true;
  11. Variables $my_string = 'bar'; // This is a comment. It

    is ignored. $my_number = 3; $my_array = array('one', 'two', 'ten'); $my_boolean = true; /* Now you've seen 4 types of data */
  12. Operations $my_age = 33; $my_nephews_age = 3; // Simple numeric

    operations: +-*/ $age_difference = $my_age - $my_nephews_age;
  13. Comparisons $my_name = 'Matt'; $dans_name = 'Dan'; $my_bosses_name = 'Matt';

    $my_name == $dans_name; // false; $my_name == $my_bosses_name;
  14. Comparisons $my_name = 'Matt'; $dans_name = 'Dan'; $my_bosses_name = 'Matt';

    $my_name == $dans_name; // false; $my_name == $my_bosses_name; // true;
  15. Comparisons $a == $b // Equal $a != $b //

    Not equal $a >= $b // $a greater than or equal to $b $a <= $b // $a less than or equal to $b $a > $b // $a greater than $b $a < $b // $a less than $b
  16. Comparisons $a == $b // Equal $a != $b //

    Not equal $a >= $b // $a greater than or equal to $b $a <= $b // $a less than or equal to $b $a > $b // $a greater than $b $a < $b // $a less than $b /* There are a lot more but that’s all we’ll cover now. */
  17. Using Comparisons if ( $a == $b ) { //

    do something } else { }
  18. Using Comparisons if ( $a == $b ) { //

    do something } else { // do something else }
  19. WordPress Functions <a href="<?php echo home_url(); ?>">Home</a> <article> <h1> <a

    href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h1> <?php the_content(); ?> </article>
  20. WordPress Functions <a href="<?php echo home_url(); ?>">Home</a> <article> <h1> <a

    href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h1> <?php the_content(); ?> </article>
  21. WordPress Functions <a href="<?php echo home_url(); ?>">Home</a> <article> <h1> <a

    href="<?php the_permalink(); ?>"> <?php echo the_title(); ?> </a> </h1> <?php the_content(); ?> </article>
  22. WordPress Functions <a href="<?php echo home_url(); ?>">Home</a> <article> <h1> <a

    href="<?php the_permalink(); ?>"> <?php echo the_title(); ?> </a> </h1> <?php the_content(); ?> </article>
  23. WordPress Functions <a href="<?php echo home_url(); ?>">Home</a> <article> <h1> <a

    href="<?php the_permalink(); ?>"> <?php echo get_the_title(); ?> </a> </h1> <?php the_content(); ?> </article>
  24. WordPress Functions ★ Read the Codex: ★ codex.wordpress.org ★ Learn

    the template hierarchy ★ codex.wordpress.org/Template_Hierarchy
  25. WordPress Functions ★ Read the Codex: ★ codex.wordpress.org ★ Learn

    the template hierarchy ★ codex.wordpress.org/Template_Hierarchy ★ Make a child theme to hack on
  26. WordPress Functions ★ Read the Codex: ★ codex.wordpress.org ★ Learn

    the template hierarchy ★ codex.wordpress.org/Template_Hierarchy ★ Make a child theme to hack on ★ codex.wordpress.org/Child_Themes