Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

Sending Text to the Browser.......................................................................


Output Buffering...............................................................................................


Files


Compressed Files


POSIX


Debugging


Session Handling..............................................................................................


Shell Commands...............................................................................................


HTTP Headers....................................................................................................


Network I/O........................................................................................................


FTP


No useful program can be useful in a vacuum. The functions described in this chapter are
concerned with I/O (Input and Output), whether it's to the browser, files, or across a
network. Some of them perform very specialized duties such as manipulating files.
Others are simply for debugging or reporting information about the environment.


If you are experienced in traditional application development, you may be challenged by
the unique characteristics of a stateless operating environment. Your script can't sit in a
loop and get input from the user until the quit button is clicked. Although there are ways
to force the preservation of state—that is, a collection of variables for each user—I
encourage you to work within PHP's world. You may come to find what at first were
limitations are refreshing opportunities.


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.

Free download pdf