O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.2. Writing to the Browser

Three functions in PHP will send text to the browser: echo, print, and printf. Each does the same thing: They take values and print them to the browser. The printf function allows you to specify the format of the output rather than sending values as-is. I've used print so far in my examples, mostly out of personal preference. I don't usually need the formatting that printf provides. Many older PHP examples you will find on the Web use echo because it existed in PHP/FI. All three functions are discussed in Chapter 8.

It is important to remember everything you write is in the context of a Web browser. Unless you take measures to make it otherwise, your output will be treated as HTML text. If you send text that is HTML ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required