When switching to PHP, there are several common mistakes even experienced programmers make. In this short section, we highlight some of these mistakes and the basics of how to rectify them.
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,
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
flush( ) function after
flush( ) empties the output buffer maintained by the PHP engine, sending all currently buffered output to the web server. The function ...