search
Homephp教程php手册PHP常见错误的具体纠正方法

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

Jun 13, 2016 am 11:06 AM
pagephpthewspecificexistcommonusmethodyesofusemistake

我们在运用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/来分析。

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

<ol class="dp-xml">
<li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span>   </span></span></li>
<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 class="tag-name">10</span><span>; $Counter++)   </span></span>
</li>
<li class="alt"><span>myFunction();   </span></li>
<li class="">
<span></span><span class="tag">?></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>
<li class=""><span>error_reporting(E_ALL);   </span></li>
<li class="alt"><span> </span></li>
<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 class="tag-name">10</span></span></font></strong><span>; $Counter++)   </span>
</li>
<li class="alt"><span>myFunction();   </span></li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span>   </span>
</li>
</ol>

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.