2.3. Sending Data to the Browser as Output

To see the data that you're processing, you need a way to send it as output. This enables you to display the contents of a variable in the browser to your users.

There are several ways to send output, but the most common methods are the commands echo(), print(), printf(), and sprintf(). There are differences in how you use each of these, but the result is the same: something is output for display in the browser.

2.3.1. The Different Output Commands

It's important to have a solid understanding of your options when sending output to the browser, so I'll go over the different statements available, how they work, and what special properties are associated with each.

NOTE

Whenever I introduce a language ...

Get PHP for Absolute Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.