我们在运用php常见错误是:
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
出现这些PHP常见错误情况的大多数原因并不在于脚本的逻辑,而是 HTML 中存在的 bug 或者脚本生成的 HTML 的 bug 。例如缺少类似 , , 之类的关闭 Tag,页面就不能刷新。解决这个问题的办法就是,查看 HTML 的源代码。
对于复杂的,不能查到原因的页面,可以通过 W3C 的页面校验程序 http://validator.w3.org/来分析。
如果没有定义变量,或者变量定义错误也会让程序变得古怪。例如下面的死循环:
立即学习“PHP免费学习笔记(深入)”;
<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>
变量 $Counter 在增加,而 $counter 永远小于 10。这类PHP常见错误一般都能通过设置较高的错误报告级别来找到:
<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>?></FONT></STRONG></SPAN><SPAN> </SPAN></SPAN></LI></OL>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号