📄 function.php-check-syntax.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Check the PHP syntax of (and execute) the specified file</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pack.html">pack</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.php-strip-whitespace.html">php_strip_whitespace</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.php-check-syntax" class="refentry"> <div class="refnamediv"> <h1 class="refname">php_check_syntax</h1> <p class="verinfo">(PHP 5 <= 5.0.4)</p><p class="refpurpose"><span class="refname">php_check_syntax</span> — <span class="dc-title"> Check the PHP syntax of (and execute) the specified file </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>php_check_syntax</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter reference">&$error_message</tt></span> ] )</div> <p class="para rdfs-comment"> Performs a syntax (lint) check on the specified <i><tt class="parameter">filename</tt></i> testing for scripting errors. </p> <p class="para"> This is similar to using <strong class="command">php -l</strong> from the <a href="features.commandline.html" class="link">commandline</a> except that this function will execute (but not output) the checked <i><tt class="parameter">filename</tt></i>. </p> <p class="para"> For example, if a function is defined in <i><tt class="parameter">filename</tt></i>, this defined function will be available to the file that executed <b>php_check_syntax()</b>, but output from <i><tt class="parameter">filename</tt></i> will be suppressed. </p> <blockquote><p><b class="note">Note</b>: For technical reasons, this function is deprecated and removed from PHP. Instead, use <i>php -l somefile.php</i> from the <a href="features.commandline.html" class="link">commandline</a>. <br /> </p></blockquote> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> The name of the file being checked. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">error_message</tt></i></span> <dd> <p class="para"> If the <i><tt class="parameter">error_message</tt></i> parameter is used, it will contain the error message generated by the syntax check. <i><tt class="parameter">error_message</tt></i> is passed by <a href="language.references.html" class="link">reference</a>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> if the lint check passed, and <b><tt>FALSE</tt></b> if the link check failed or if <i><tt class="parameter">filename</tt></i> cannot be opened. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.5</td> <td colspan="1" rowspan="1" align="left"> This function was removed from PHP. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.3</td> <td colspan="1" rowspan="1" align="left"> Calling <a href="function.exit.html" class="function">exit()</a> after <b>php_check_syntax()</b> resulted in a Segfault. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.1</td> <td colspan="1" rowspan="1" align="left"> <i><tt class="parameter">error_message</tt></i> is passed by reference. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example-contents"><pre><div class="cdata"><pre>php -l somefile.php</pre></div> </pre></div> </p> <p class="para">The above example will output something similar to:</p> <p class="para"> <div class="example-contents"><pre><div class="cdata"><pre>PHP Parse error: unexpected T_STRING in /tmp/somefile.php on line 81</pre></div> </pre></div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><b>include()</b></li> <li class="member"><a href="function.is-readable.html" class="function" rel="rdfs-seeAlso">is_readable()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pack.html">pack</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.php-strip-whitespace.html">php_strip_whitespace</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -