<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.4 $ -->
<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>&amp;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 <literal>php -l</literal>
     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 from the syntax check. <parameter>error_message
     </parameter> must be passed in 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
-->