Sending Data to the Web Browser

If you’re already tired of creating useless scripts that generate blank pages, rest assured that PHP can do a lot more than, well, nothing. To build dynamic Web sites with PHP, you begin with knowing how to send data to the Web browser. PHP has a number of built-in functions written specifically to accomplish this, the most common being echo() and print().

echo 'Hello, world!';
print "It's nice to see you.";

As you can see from the above, either single or double quotation marks will work (the distinction between the two will be made clear by the chapter’s end). Also note that in PHP all statements (a line of executed code, in layman’s terms) must end with a semicolon.

Looking for an Escape

As you might discover, ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide 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.