CVS update: php3/doc/chapters

From: Date: Sat, 15 May 1999 08:36:13 +0000
Subject: CVS update: php3/doc/chapters
Groups: php.dev 
Request: Send a blank email to php-dev+get-5633@lists.php.net to get a copy of this message
Date: Saturday May 15, 1999 @ 4:36 Author: cslawi Update of /repository/php3/doc/chapters In directory php:/tmp/cvs-serv23978/chapters Modified Files: lang-const.sgml Log Message: Documented the rest of the predefined constants; added more notes on what constants can('t) do. Index: php3/doc/chapters/lang-const.sgml diff -u php3/doc/chapters/lang-const.sgml:1.37 php3/doc/chapters/lang-const.sgml:1.38 --- php3/doc/chapters/lang-const.sgml:1.37 Sun May 9 01:15:15 1999 +++ php3/doc/chapters/lang-const.sgml Sat May 15 04:36:13 1999 @@ -16,31 +16,134 @@ <title>Constants</title> <simpara> - PHP defines a few constants and provides a mechanism for defining - more at run-time. Constants are much like variables, but they have - a slightly different syntax. + PHP defines several constants and provides a mechanism for defining + more at run-time. Constants are much like variables, save for the two + facts that constants must be defined using the + <function>define</function> function, and that they cannot later + be redefined to another value. <para> - The pre-defined constants are __FILE__ and __LINE__, which - correspond to the filename and line number being processed when - they are encountered. + The predefined constants (always available) are: - <example> - <title>Using __FILE__ and __LINE__</title> - <programlisting> -&lt;?php -function report_error($file, $line, $message) { - echo "An error occured in $file on line $line: $message."; -} + <variablelist> -report_error(__FILE__,__LINE__, "Something went wrong!"); -?&gt; - </programlisting> - </example> + <varlistentry> + <term>__FILE__</term> + <listitem> + <simpara> + The name of the script file presently being parsed. If used + within a file which has been included or required, then the + name of the included file is given, and not the name of the + parent file. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>__LINE__</term> + <listitem> + <simpara> + The number of the line within the current script file which is + being parsed. If used within a file which has been included or + required, then the position within the included file is given. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>PHP_VERSION</term> + <listitem> + <simpara> + The string representation of the version of the PHP parser + presently in use; e.g. '3.0.8-dev'. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>PHP_OS</term> + <listitem> + <simpara> + The name of the operating system on which the PHP parser is + executing; e.g. 'Linux'. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>TRUE</term> + <listitem> + <simpara> + A true value. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>FALSE</term> + <listitem> + <simpara> + A false value. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>E_ERROR</term> + <listitem> + <simpara> + Denotes an error other than a parsing error from which + recovery is not possible. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>E_WARNING</term> + <listitem> + <simpara> + Denotes a condition where PHP knows something is wrong, but + will continue anyway; these can be caught by the script + itself. An example would be an invalid regexp in + <function>ereg</function>. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>E_PARSE</term> + <listitem> + <simpara> + The parser choked on invalid syntax in the script + file. Recovery is not possible. + </simpara> + </listitem> + </varlistentry> + + <varlistentry> + <term>E_NOTICE</term> + <listitem> + <simpara> + Something happened which may or may not be an error. Execution + continues. Examples include using an unquoted string as a + hash index, or accessing a variable which has not been set. + </simpara> + </listitem> + </varlistentry> + </variablelist> + + <para> + The E_* constants are typically used with the + <function>error_reporting</function> function for setting the + error reporting level. <para> You can define additional constants using the <function>define</function> function. + + <para> + Note that these are constants, not C-style macros; only valid + scalar data may be represented by a constant. <example> <title>Defining Constants</title> @@ -52,6 +155,20 @@ </programlisting> </example> + <example> + <title>Using __FILE__ and __LINE__</title> + <programlisting> +&lt;?php +function report_error($file, $line, $message) { + echo "An error occured in $file on line $line: $message."; +} + +report_error(__FILE__,__LINE__, "Something went wrong!"); +?&gt; + </programlisting> + </example> + </sect1> + <sect1 id="expressions"> <title>Expressions</title> -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5633) next »