uTools-Manuals/docs/php/php_check_syntax.html
2019-04-08 23:22:26 +08:00

158 lines
5.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>检查PHP的语法并执行指定的文件</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.php-check-syntax" class="refentry">
<div class="refnamediv">
<h1 class="refname">php_check_syntax</h1>
<p class="verinfo">(PHP 5 &lt; 5.0.5)</p><p class="refpurpose"><span class="refname">php_check_syntax</span> &mdash; <span class="dc-title">
检查PHP的语法并执行指定的文件
</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.php-check-syntax-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>php_check_syntax</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
[, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_message</code></span>
] ) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
对指定的 <code class="parameter">filename</code> 进行语法检查,检测脚本的错误。
</p>
<p class="para">
此函数除了会执行(但不会输出)<code class="parameter">filename</code>,其他与 <a href="features.commandline.html" class="link">命令行</a>中使用<strong class="command">php -l</strong> 相似。
</p>
<p class="para">
例如,如果函数在文件 <code class="parameter">filename</code> 中被定义了,则该函数在执行<span class="function"><strong>php_check_syntax()</strong></span>后可用。但是<code class="parameter">filename</code>输出内容不会被输出。
</p>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
因为某些技术原因该函数已被弃用并且从PHP中移除了。请以<a href="features.commandline.html" class="link">commandline</a>使用 <em>php -l somefile.php</em>取而代之。
</p>
</p></blockquote>
</div>
<div class="refsect1 parameters" id="refsect1-function.php-check-syntax-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">filename</code></dt>
<dd>
<p class="para">
需要被检测的文件。
</p>
</dd>
<dt>
<code class="parameter">error_message</code></dt>
<dd>
<p class="para">
如果使用了参数 <code class="parameter">error_message</code>,它会包含语法检测出的错误信息。
<code class="parameter">error_message</code><a href="language.references.html" class="link">引用</a>方式传递。
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.php-check-syntax-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
如果语法检测通过返回 <strong><code>TRUE</code></strong>,未通过或者文件无法打开则返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 changelog" id="refsect1-function.php-check-syntax-changelog">
<h3 class="title">更新日志</h3>
<p class="para">
<table class="doctable informaltable">
<thead>
<tr>
<th>版本</th>
<th>说明</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>5.0.5</td>
<td>
函数从PHP中移除。
</td>
</tr>
<tr>
<td>5.0.3</td>
<td>
<span class="function"><strong>php_check_syntax()</strong></span>之后调用 <span class="function"><a href="exit.html" class="function">exit()</a></span> 会导致一个段错误。
</td>
</tr>
<tr>
<td>5.0.1</td>
<td>
<code class="parameter">error_message</code> 通过引用传递
</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.php-check-syntax-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">php -l somefile.php</pre>
</div>
</div>
</p>
<p class="para">以上例程的输出类似于:</p>
<p class="para">
<div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">PHP Parse error: unexpected T_STRING in /tmp/somefile.php on line 81</pre>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.php-check-syntax-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="include.html" class="function" rel="rdfs-seeAlso">include</a> - include</span></li>
<li class="member"><span class="function"><a href="is_readable.html" class="function" rel="rdfs-seeAlso">is_readable()</a> - 判断给定文件名是否可读</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>