Chapter 2. PHP Meets HTML
With your first PHP script under your belt, youâve made some real progress. But that PHP script might not have been what you expected. Most web developers donât fall asleep at night dreaming of seeing this in a terminal window:
Hello there. So I hear you're learning to be a PHP programmer! Why don't you type in your name for me: Brett Thanks, Brett, it's really nice to meet you.
Even less impressive than its complexity (or lack thereof) is the scriptâs format. Itâs just plain text. Thereâs no formatting; in other words, no HTML.
In this chapter, youâre going to inject HTML into your scripts. No command-line prompts and boring text. By the time youâre through, your script will be speaking the language of the WebâHTML. In addition, youâll see how PHP does one of its core tasks: respond to an HTML form.
Script or HTML?
Before you can start doing fancy party tricks with PHP, youâve got to get over a bit of a conceptual hurdle. So far in your web programming journey, youâre probably used to thinking about the technologies youâve learned in strict categories: HTML is markup, the structure of your page; CSS applies style to that structure; and JavaScript adds some interaction, with everything from alert boxes to validation, redirection, and widgets.
In the process, you probably also built some syntax categories. Your HTML is angle brackets, <title>
and <head>
and <ul>
, and the like. CSS is curly braces and style keywords like p.warning
and ...
Get PHP & MySQL: The Missing Manual, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.