Sending Data to the Web Browser

To build dynamic Web sites with PHP, you must know how to send data to the Web browser. PHP has a number of built-in functions for this purpose, the most common being echo() and print().

echo 'Hello, world!';

print "It's nice to see you.";

As you can see from this example, either single or double quotation marks will work with either function (the distinction between the two types of quotation marks 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, one of the complications with sending data to the Web involves printing single and double quotation marks. Either of the ...

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