Sending Text to the Browser

Any text outside PHP tags is automatically sent to the browser. This is as you would expect. Chapter 18, "Network" deals with the decision to send text via a PHP function. PHP offers three functions that simply send text to the browser: echo, print, and printf.

The echo string first, string second, . . ., string last

The echo function sends any number of parameters, separated by commas, to the browser. Each will be converted to a string and printed with no space between them. Unlike most other PHP functions, the echo function does not require parentheses. In fact, echo is more of a statement than a function.

<?
   echo "First string", 2, 3.4, "last string";
?>

flush()

As text is sent to the browser via functions like ...

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