A Page That Produces Partial or No Output
One of the most common problems in debugging PHP scripts is seeing:
No page rendered by the web browser when much more is expected
A pop-up dialog box stating that the "Document Contains No Data"
A partial page when more is expected
Most of these problems are caused not by a bug in script-programming logic, but by a bug in the HTML produced by the script. For example, if the
</frame> closing tags are omitted, the page may not be rendered.
The HTML problem can usually be identified by viewing the HTML page source using the web browser. With Netscape, the complete output of the erroneous example is shown in the page-source view, and the HTML problem can hopefully be easily identified.
For compound or hard-to-identify HTML bugs, the W3C validator at
http://validator.w3.org retrieves a page, analyzes the correctness of the HTML, and issues a report. It's an excellent assistant for debugging and last-minute compliance checks before delivery of an application.
If the problem still proves hard to find, consider adding calls to the
flush( ) function after
flush( ) empties the output buffer maintained by the PHP engine, sending all currently buffered output to the web server. The function has no effect on buffering at the web server or the web browser, but it ensures that all data output by the script is available to the web server to be transmitted and rendered by a browser. Remember to remove the
flush( ) function calls after debugging, because unnecessary flushing may prevent efficient buffering of output by the PHP scripting engine.
A common problem that shouldn't be confused with those described here is not receiving a response from the web server and getting a "no response" error message. This problem is a symptom of the bugs described in the next section, and can be distinguished from the problems described here by observing the web browser. Most of the popular graphical browsers show they are waiting for a response by animating the logo in the top-right corner. For the HTML problems described here, the page loading process will be complete, the logo animation will have stopped, and the HTML page source can be viewed through the web browser menus.updated