首页 > php框架 > PHP常见错误的具体纠正方法

PHP常见错误的具体纠正方法

我们在运用
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 。例如缺少类似 </table>, </form>, </frame> 之类的关闭 Tag,页面就不能刷新。解决这个问题的办法就是,查看 HTML 的源代码。

对于复杂的,不能查到原因的页面,可以通过 W3C 的页面校验程序 http://validator.w3.org/来分析。

如果没有定义变量,或者变量定义错误也会让程序变得古怪。例如下面的死循环:

  1. <?php   
  2. for($counter=0; $counter<10; $Counter++)   
  3. myFunction();   
  4. ?>   

变量 $Counter 在增加,而 $counter 永远小于 10。这类PHP常见错误一般都能通过设置较高的错误报告级别来找到:

  1. <?php   
  2. error_reporting(E_ALL);   
  3.  
  4. for($counter=0; $counter<10; $Counter++)   
  5. myFunction();   
  6. ?>   


文章链接:http://www.phprm.com/frame/php1003601.html

随便收藏,请保留本文地址!

标签:none

发表留言