INST 377 Lecture 16: INST377 Lecture 16: Intro to PHP
SchoolUniversity of Maryland
Course CodeINST 377
This preview shows half of the first page. to view the full 2 pages of the document.
INST377 Lecture 16: Intro to PHP
In Chapter 1, I explained that PHP is the language that you use to make the server generate
dynamic output—output that is potentially different each time a browser requests a page. In this
chapter, you’ll start learning this simple but powerful lan‐ guage; it will be the topic of the
following chapters up through Chapter 7.
I encourage you to develop your PHP code in one of the IDEs listed in Chapter 2. It will help you
catch typos and speed up learning tremendously in comparison to less feature-rich editors.
Many of these development environments let you run the PHP code and see the out‐ put
discussed in this chapter. I’ll also show you how to embed the PHP in an HTML file so that you
can see what the output looks like in a web page (the way your users will ultimately see it). But
that step, as thrilling as it may be at first, isn’t really impor‐ tant at this stage.
MySQL statements laid out using CSS, and possibly utilizing various HTML5 elements.
Furthermore, each page can lead to other pages to provide users with ways to click through
links and fill out forms. We can avoid all that complexity while learning each language, though.
Focus for now on just writing PHP code and making sure that you get the output you expect—or
at least that you understand the output you actually get!
Incorporate PHP into HTML
By default, PHP documents end with the extension .php. When a web server encoun‐ ters this
extension in a requested file, it automatically passes it to the PHP processor. Of course, web
servers are highly configurable, and some web developers choose to force files ending with
.htm or .html to also get parsed by the PHP processor, usually because they want to hide the
fact that they are using PHP.
Your PHP program is responsible for passing back a clean file suitable for display in a web
browser. At its very simplest, a PHP document will output only HTML. To prove this, you can
take any normal HTML document such as an index.html file and save it as index.php, and it will
display identically to the original.
To trigger the PHP commands, you need to learn a new tag. Here is the first part:
The first thing you may notice is that the tag has not been closed. This is because entire
sections of PHP can be placed inside this tag, and they finish only when the closing part is
encountered, which looks like this:
You're Reading a Preview
Unlock to view full version