Slide 1

Slide 1 text

PHP for WordPress JOE CASABONA

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

What is PHP? ◦ Interpreted Programming Language ◦ Compare to HTML, CSS, Javascript ◦ Processed by Server ◦ Often used to talk to Databases ◦ Allows for more dynamic content

Slide 4

Slide 4 text

Anatomy of a PHP Program ◦ PHP files must end in .php ◦ PHP code opens with

Slide 5

Slide 5 text

Hello World Script

Hello World

Hello World, HTML

Slide 6

Slide 6 text

Hello World Script

Hello World, PHP

Slide 7

Slide 7 text

Variables Variables are a way to store information in order to reference it later. Variables can be used to store names, numbers, and other important data. All PHP programs, including WordPress, heavily use variables. $age = 30;

Slide 8

Slide 8 text

Variables Variables can be letters/symbols (characters), words/phrases (Strings), or numbers (integer or decimals/floats) $age = 30; $average = 27.5; $name = “Joe”; $first_letter = ‘J’;

Slide 9

Slide 9 text

Arrays Arrays are different from other variables. Arrays act as 
 key -> value pairs. Let’s look at a collection of colors on the next slide. We have an array of size 4 (there are 4 elements), and we can access any one of these by referencing its key, or index. Indexing starts at 0 for arrays, so an array of size 4 will have indexes 0-3.

Slide 10

Slide 10 text

Arrays

Slide 11

Slide 11 text

Arrays ‘Joe Casabona’, ‘age’ => 30, ‘profession’ => ‘Web Developer’); ?>

Slide 12

Slide 12 text

CONTROL STRUCTURES Control Structures are used in PHP to employ logic to our code. They are what do the decision making. The most common of these control structures is if statements.

Slide 13

Slide 13 text

If Statements

Slide 14

Slide 14 text

If Statements = 5 ) { echo “10 is greater than or equal to 5”; } else { echo “10 is not greater than or equal to 5.”; } ?>

Slide 15

Slide 15 text

Logic Operators == != > < >= <= && || ===

Slide 16

Slide 16 text

Loops Loops are used to repeat code or continually check the condition of a statement. They are a fundamental part of WordPress; the important portion of WordPress code is called “the Loop.” We will look at two types of loops: While Loops and Foreach Loops.

Slide 17

Slide 17 text

While Loop $i”; $i = $i + 1; } ?>

Slide 18

Slide 18 text

For Each Loop $color”; } ?>

Slide 19

Slide 19 text

Functions Functions are reusable snippets of code that can be called multiple times. You can imagine functions as variables for blocks of code. Functions can do one of two things: Return a variable or print something out.

Slide 20

Slide 20 text

Functions = 5; } ?>

Slide 21

Slide 21 text

Functions = $b; } $bigger = is_bigger(10, 5); ?>

Slide 22

Slide 22 text

Any Questions? Joe Casabona Front End Developer wpinonemonth.com