Source of: /manual/en/function.php-check-syntax.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.misc.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.php-check-syntax.php',
1 => 'php_check_syntax',
),
'up' =>
array (
0 => 'ref.misc.php',
1 => 'Misc. Functions',
),
'prev' =>
array (
0 => 'function.pack.php',
1 => 'pack',
),
'next' =>
array (
0 => 'function.php-strip-whitespace.php',
1 => 'php_strip_whitespace',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<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>
<a name="function.php-check-syntax.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">bool</span> <span class="methodname"><b>php_check_syntax</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.php" 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.php" class="link">commandline</a>.
<br />
</p></blockquote>
</div>
<a name="function.php-check-syntax.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">filename</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The name of the file being checked.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">error_message</tt></i>
</span>
</dt><dd class="listitem">
<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.php" class="link">reference</a>.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.php-check-syntax.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns <b><tt class="constant">TRUE</tt></b> if the lint check passed, and <b><tt class="constant">FALSE</tt></b> if the link check
failed or if <i><tt class="parameter">filename</tt></i>
cannot be opened.
</p>
</div>
<a name="function.php-check-syntax.changelog"></a><div class="refsect1 changelog">
<h3 class="title">Changelog</h3>
<p class="para">
</p><table class="doctable informaltable">
<thead valign="middle">
<tr valign="middle">
<th>Version</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="middle" class="tbody">
<tr valign="middle">
<td align="left">5.0.5</td>
<td align="left">
This function was removed from PHP.
</td>
</tr>
<tr valign="middle">
<td align="left">5.0.3</td>
<td align="left">
Calling <a href="function.exit.php" class="function">exit()</a> after
<b>php_check_syntax()</b> resulted in a Segfault.
</td>
</tr>
<tr valign="middle">
<td align="left">5.0.1</td>
<td align="left">
<i><tt class="parameter">error_message</tt></i>
is passed by reference.
</td>
</tr>
</tbody>
</table>
<p>
</p>
</div>
<a name="function.php-check-syntax.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</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">The above example will output
something similar to:</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>
<a name="function.php-check-syntax.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.include.php" class="function" rel="rdfs-seeAlso">include()</a> - include</li>
<li class="member"><a href="function.is-readable.php" class="function" rel="rdfs-seeAlso">is_readable()</a> - Tells whether a file exists and is readable</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>