HTML and CSS Reference
Why Do We Need It?
Your app will be leveraging several of PHP's features to add functionality into the app, such as these:
• Generating output dynamically to customize the app's display: Things like the user's name,
the name of the current “room,” and the name of the presenter will need to be inserted into
the HTML markup dynamically.
• Hooking into the Pusher API to enable realtime communication: We'll go over this later in
this chapter, and in detail in Chapter 3.
What Role Does It Play?
far as processing the data sent to the app by our users and sending back processed responses to various user requests.
How Does It Work?
PHP is a preprocessor , which means that it does its calculations and data manipulation prior to the page being
rendered. This means that PHP code is embedded into the markup, and the server reads the PHP and replaces it with
the proper output before it delivers the markup to the browser.
■ this topic assumes a working knowledge of php, so basic concepts and syntax will not be covered. If you want
to brush up on your php chops, get your hands on PHP for Absolute Beginners, 8 by Jason lengstorf.
eXerCISe 2-4: USe php tO INSert DYNaMIC CONteNt
let's experiment with php by inserting the current date into our markup dynamically. to do this, we need to save
a new copy of our htMl as a php file, which we'll name 04.php .
Next, let's insert some php at the very top of the file, just above the <!doctype> declaration:
// Set the timezone and generate two formatted date strings
$datetime = date('c');
$date_fmt = date('F d, Y');
as the comment indicates, this code sets the time zone to the pacific time zone and then stores two formatted
date strings in variables.