Home >Backend Development >PHP Tutorial >Specific methods to correct common PHP errors_PHP Tutorial

Specific methods to correct common PHP errors_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-15 13:29:27849browse

Common mistakes we make when using PHP are:

No page rendered by the Web browser when much more is expected

A pop-up dialog stating that the " Document Contains No Data"

A partial page when more is expected

Most of the reasons for these common PHP errors do not lie in the logic of the script, but in the bugs in the HTML or the HTML generated by the script. bug. For example, if closing tags like , , are missing, the page cannot be refreshed. The solution to this problem is to look at the source code of the HTML.

For complex pages whose reasons cannot be found, you can analyze them through the W3C page validation program http://validator.w3.org/.

If the variable is not defined, or the variable definition is wrong, the program will become weird. For example, the following infinite loop:

<ol class="dp-xml"><li class="alt"><span><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN><SPAN>   </SPAN></SPAN><LI class=""><SPAN>for($</SPAN><SPAN class=attribute>counter</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>0</SPAN><SPAN>; $counter</SPAN><SPAN class=tag><</SPAN><SPAN class=tag-name>10</SPAN><SPAN>; $Counter++)   </SPAN></SPAN><LI class=alt><SPAN>myFunction();   </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag>?></span><span>   </span></span></li></ol>

The variable $Counter is increasing while $counter is always less than 10. Such common PHP errors can generally be found by setting a higher error reporting level:

<ol class="dp-xml"><li class="alt">
<span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN>   </SPAN></SPAN><LI class=""><SPAN>error_reporting(E_ALL);   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>for($</SPAN><SPAN class=attribute><FONT color=#ff0000>counter</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>0</FONT></SPAN><SPAN>; $counter</SPAN><STRONG><FONT color=#006699><SPAN class=tag><</SPAN><SPAN class=tag-name>10</SPAN></FONT></STRONG><SPAN>; $Counter++)   </SPAN></SPAN><LI class=alt><SPAN>myFunction();   </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span>   </span>
</li></ol>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446368.htmlTechArticleThe common mistakes we make when using PHP are: No page rendered by the Web browser when much more is expected A pop-up dialog stating that the "Document Contains No Data" A partial page whe...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn