mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 18:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@167315 c90b9560-bf6c-de11-be94-00142212c4b1
83 lines
2.4 KiB
XML
83 lines
2.4 KiB
XML
<?xml version='1.0' encoding='iso-8859-1'?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<refentry id="function.php-check-syntax">
|
|
<refnamediv>
|
|
<refname>php_check_syntax</refname>
|
|
<refpurpose>
|
|
Check the PHP syntax of the specified file
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>php_check_syntax</methodname>
|
|
<methodparam><type>string</type><parameter>file_name</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>&error_message</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
The <function>php_check_syntax</function> function performs a syntax
|
|
(lint) check on the specified <parameter>filename</parameter> testing
|
|
for scripting errors. This is similar to using <command>php -l</command>
|
|
from the <link linkend="features.commandline">commandline</link>.
|
|
</simpara>
|
|
<simpara>
|
|
If the <parameter>error_message</parameter> parameter is used, it will
|
|
contain the error message generated by the syntax check. <parameter>error_message
|
|
</parameter> is passed by <link linkend="language.references">
|
|
reference</link>.
|
|
</simpara>
|
|
<para>
|
|
The following example shows how this function can be used.
|
|
<example>
|
|
<title><function>php_check_syntax</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$error_message = "";
|
|
$filename = "./tests.php";
|
|
|
|
if(!php_check_syntax($filename, $error_message)) {
|
|
printf("Errors were found in the file %s:\n\n%s\n", $filename, $error_message);
|
|
} else {
|
|
printf("The file %s contained no syntax errors.", $filename);
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<simpara>
|
|
The output of the above script could look something like this:
|
|
</simpara>
|
|
<screen>
|
|
<![CDATA[
|
|
Errors were found in the file ./tests.php:
|
|
|
|
parse error, unexpected T_STRING in /tmp/tests.php on line 81
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|