O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites 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

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 PHP2. I avoid it, because it behaves more like an operator than a function. 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 ...

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