cvs: phpdoc /kr/appendices debugger.xml escaping.xml history.xml migration.xml phpdevel.xml
| From: | Younsoo Kim | Date: | Fri, 12 Jan 2001 04:10:48 +0000 |
| Subject: | cvs: phpdoc /kr/appendices debugger.xml escaping.xml history.xml migration.xml phpdevel.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969333566@lists.php.net to get a copy of this message | ||
corean Thu Jan 11 20:10:48 2001 EDT
Modified files:
/phpdoc/kr/appendices debugger.xml escaping.xml history.xml
migration.xml phpdevel.xml
Log:
¹ø¿ªÇÔ. (°ú¿¬ ¹ø¿ªÀ̶ó°í ÇÒ¼ö ÀÖÀ»±î..) by corean
Index: phpdoc/kr/appendices/debugger.xml diff -u phpdoc/kr/appendices/debugger.xml:1.2 phpdoc/kr/appendices/debugger.xml:1.3 --- phpdoc/kr/appendices/debugger.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/debugger.xml Thu Jan 11 20:10:47 2001 @@ -1,10 +1,8 @@ - <appendix id="debugger"> - <title>The PHP Debugger</title> - - <sect1 id="debugger-using"> - <title>Using the Debugger</title> - - <para> +<appendix id="debugger"> + <title>The PHP Debugger</title> + <sect1 id="debugger-using"> + <title>Using the Debugger</title> + <para> PHP's internal debugger is useful for tracking down evasive bugs. The debugger works by connecting to a <acronym>TCP</acronym> port for every time PHP starts up. All error messages from that @@ -12,47 +10,45 @@ intended for "debugging server" that can run inside an <acronym>IDE</acronym> or programmable editor (such as Emacs). </para> - <para> + <para> How to set up the debugger: <orderedlist> - <listitem> - <simpara> - Set up a TCP port for the debugger in the <link - linkend="configuration.file">configuration file</link> (<link - linkend="ini.debugger.port">debugger.port</link>) and enable it + <listitem> + <simpara> + Set up a TCP port for the debugger in the <link linkend="configuration.file">configuration file</link> (<link linkend="ini.debugger.port">debugger.port</link>) and enable it (<link linkend="ini.debugger.enabled">debugger.enabled</link>). </simpara> - </listitem> - <listitem> - <simpara> + </listitem> + <listitem> + <simpara> Set up a TCP listener on that port somewhere (for example <command>socket -l -s 1400</command> on UNIX). </simpara> - </listitem> - <listitem> - <simpara> + </listitem> + <listitem> + <simpara> In your code, run "debugger_on(<replaceable>host</replaceable>)", where <replaceable>host</replaceable> is the IP number or name of the host running the <acronym>TCP</acronym> listener. </simpara> - </listitem> - </orderedlist> + </listitem> + </orderedlist> Now, all warnings, notices etc. will show up on that listener socket, <emphasis>even if you them turned off with - <function>error_reporting</function></emphasis>. + <function>error_reporting</function> + </emphasis>. </para> - <note> - <para> + <note> + <para> The code for the debugger has not been ported to PHP 4, at the present time only PHP 3 supports the debugger code. </para> - </note> - </sect1> - - <sect1 id="debugger-protocol"> - <title>Debugger Protocol</title> - <para> + </note> + </sect1> + <sect1 id="debugger-protocol"> + <title>Debugger Protocol</title> + <para> The debugger protocol is line-based. Each line has a <emphasis>type</emphasis>, and several lines compose a <emphasis>message</emphasis>. Each message starts with a line of @@ -60,178 +56,228 @@ the type <literal>end</literal>. PHP may send lines for different messages simultaneously. </para> - <para> + <para> A line has this format: <informalexample> - <literallayout> -<replaceable>date</replaceable> <replaceable>time</replaceable> -<replaceable>host</replaceable>(<replaceable>pid</replaceable>) + <literallayout> + <replaceable>date</replaceable> + <replaceable>time</replaceable> + <replaceable>host</replaceable>(<replaceable>pid</replaceable>) <replaceable>type</replaceable>: <replaceable>message-data</replaceable> - </literallayout> - </informalexample> - <variablelist> - <varlistentry> - <term><replaceable>date</replaceable></term> - <listitem> - <simpara> + </literallayout> + </informalexample> + <variablelist> + <varlistentry> + <term> + <replaceable>date</replaceable> + </term> + <listitem> + <simpara> Date in ISO 8601 format (<replaceable>yyyy</replaceable>-<replaceable>mm</replaceable>-<replaceable>dd</replaceable>) </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>time</replaceable></term> - <listitem> - <simpara>Time including microseconds: + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>time</replaceable> + </term> + <listitem> + <simpara>Time including microseconds: <replaceable>hh</replaceable>:<replaceable>mm</replaceable>:<replaceable>uuuuuu</replaceable> - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>host</replaceable></term> - <listitem> - <simpara> + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>host</replaceable> + </term> + <listitem> + <simpara> DNS name or IP address of the host where the script error was generated. </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>pid</replaceable></term> - <listitem> - <simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>pid</replaceable> + </term> + <listitem> + <simpara> PID (process id) on <replaceable>host</replaceable> of the process with the PHP script that generated this error. </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>type</replaceable></term> - <listitem> - <para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>type</replaceable> + </term> + <listitem> + <para> Type of line. Tells the receiving program about what it should treat the following data as: <table> - <title>Debugger Line Types</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Name</entry> - <entry>Meaning</entry> - </row> - </thead> - <tbody> - <row> - <entry><literal>start</literal></entry> - <entry> + <title>Debugger Line Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Name</entry> + <entry>Meaning</entry> + </row> + </thead> + <tbody> + <row> + <entry> + <literal>start</literal> + </entry> + <entry> Tells the receiving program that a debugger message starts here. The contents of <replaceable>data</replaceable> will be the type of error message, listed below. </entry> - </row> - <row> - <entry><literal>message</literal></entry> - <entry>The PHP error message.</entry> - </row> - <row> - <entry><literal>location</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>message</literal> + </entry> + <entry>The PHP error message.</entry> + </row> + <row> + <entry> + <literal>location</literal> + </entry> + <entry> File name and line number where the error occured. The first <literal>location</literal> line will always contain the top-level location. <replaceable>data</replaceable> will contain - <literal><replaceable>file</replaceable>:<replaceable>line</replaceable></literal>. + <literal> + <replaceable>file</replaceable>:<replaceable>line</replaceable> + </literal>. There will always be a <literal>location</literal> line after <literal>message</literal> and after every <literal>function</literal>. </entry> - </row> - <row> - <entry> - <literal>frames</literal></entry> <entry>Number of frames + </row> + <row> + <entry> + <literal>frames</literal> + </entry> + <entry>Number of frames in the following stack dump. If there are four frames, expect information about four levels of called functions. If no "frames" line is given, the depth should be assumed to be 0 (the error occured at top-level). </entry> - </row> - <row> - <entry> - <literal>function</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>function</literal> + </entry> + <entry> Name of function where the error occured. Will be repeated once for every level in the function call stack. </entry> - </row> - <row> - <entry><literal>end</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>end</literal> + </entry> + <entry> Tells the receiving program that a debugger message ends here. </entry> - </row> - </tbody> - </tgroup> - </table> - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>data</replaceable></term> - <listitem> - <simpara>Line data.</simpara> - </listitem> - </varlistentry> - </variablelist> - - <table> - <title>Debugger Error Types</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Debugger</entry> - <entry>PHP Internal</entry> - </row> - </thead> - <tbody> - <row> - <entry><errortype>warning</errortype></entry> - <entry><errortype>E_WARNING</errortype></entry> - </row> - <row> - <entry><errortype>error</errortype></entry> - <entry><errortype>E_ERROR</errortype></entry> - </row> - <row> - <entry><errortype>parse</errortype></entry> - <entry><errortype>E_PARSE</errortype></entry> - </row> - <row> - <entry><errortype>notice</errortype></entry> - <entry><errortype>E_NOTICE</errortype></entry> - </row> - <row> - <entry><errortype>core-error</errortype></entry> - <entry><errortype>E_CORE_ERROR</errortype></entry> - </row> - <row> - <entry><errortype>core-warning</errortype></entry> - <entry><errortype>E_CORE_WARNING</errortype></entry> - </row> - <row> - <entry><errortype>unknown</errortype></entry> - <entry>(any other)</entry> - </row> - </tbody> - </tgroup> - </table> - - <example> - <title>Example Debugger Message</title> - <literallayout> + </row> + </tbody> + </tgroup> + </table> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>data</replaceable> + </term> + <listitem> + <simpara>Line data.</simpara> + </listitem> + </varlistentry> + </variablelist> + <table> + <title>Debugger Error Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Debugger</entry> + <entry>PHP Internal</entry> + </row> + </thead> + <tbody> + <row> + <entry> + <errortype>warning</errortype> + </entry> + <entry> + <errortype>E_WARNING</errortype> + </entry> + </row> + <row> + <entry> + <errortype>error</errortype> + </entry> + <entry> + <errortype>E_ERROR</errortype> + </entry> + </row> + <row> + <entry> + <errortype>parse</errortype> + </entry> + <entry> + <errortype>E_PARSE</errortype> + </entry> + </row> + <row> + <entry> + <errortype>notice</errortype> + </entry> + <entry> + <errortype>E_NOTICE</errortype> + </entry> + </row> + <row> + <entry> + <errortype>core-error</errortype> + </entry> + <entry> + <errortype>E_CORE_ERROR</errortype> + </entry> + </row> + <row> + <entry> + <errortype>core-warning</errortype> + </entry> + <entry> + <errortype>E_CORE_WARNING</errortype> + </entry> + </row> + <row> + <entry> + <errortype>unknown</errortype> + </entry> + <entry>(any other)</entry> + </row> + </tbody> + </tgroup> + </table> + <example> + <title>Example Debugger Message</title> + <literallayout> 1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice 1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable 1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (null):7 @@ -240,12 +286,10 @@ 1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10 1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice </literallayout> - </example> - </para> - </sect1> - - </appendix> - + </example> + </para> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml Index: phpdoc/kr/appendices/escaping.xml diff -u phpdoc/kr/appendices/escaping.xml:1.2 phpdoc/kr/appendices/escaping.xml:1.3 --- phpdoc/kr/appendices/escaping.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/escaping.xml Thu Jan 11 20:10:47 2001 @@ -1,4 +1,4 @@ -<chapt>Escaping data +<chapt>Escaping data <sect>PHP string escape chars <sect>URL encoding (GET) <sect>POST method Index: phpdoc/kr/appendices/history.xml diff -u phpdoc/kr/appendices/history.xml:1.2 phpdoc/kr/appendices/history.xml:1.3 --- phpdoc/kr/appendices/history.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/history.xml Thu Jan 11 20:10:47 2001 @@ -1,3 +1,3 @@ -<chapt>PHP's history +<chapt>PHP's history <sect>Overview of PHP's development Index: phpdoc/kr/appendices/migration.xml diff -u phpdoc/kr/appendices/migration.xml:1.2 phpdoc/kr/appendices/migration.xml:1.3 --- phpdoc/kr/appendices/migration.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/migration.xml Thu Jan 11 20:10:47 2001 @@ -1,91 +1,85 @@ -<appendix id="migration"> - <title>Migrating from PHP/FI 2.0 to PHP 3.0</title> - - <sect1 id="migration-about"> - <title>About the incompatbilities in 3.0</title> - <simpara> - PHP 3.0 is rewritten from the ground up. It has a proper parser - that is much more robust and consistent than 2.0's. 3.0 is also - significantly faster, and uses less memory. However, some of - these improvements have not been possible without compatibility - changes, both in syntax and functionality.</simpara> - - <simpara> - In addition, PHP's developers have tried to clean up both PHP's - syntax and semantics in version 3.0, and this has also caused some - incompatibilities. In the long run, we believe that these changes - are for the better.</simpara> - - <simpara> - This chapter will try to guide you through the incompatibilities - you might run into when going from PHP/FI 2.0 to PHP 3.0 and help - you resolve them. New features are not mentioned here unless - necessary.</simpara> - - <simpara> - A conversion program that can automatically convert your old - PHP/FI 2.0 scripts exists. It can be found in the <filename class="directory">convertor</filename> subdirectory of the PHP 3.0 - distribution. This program only catches the syntax changes though, - so you should read this chapter carefully anyway.</simpara></sect1> - - <sect1 id="migration-startendtags"> - <title>Start/end tags</title> - - <para> - The first thing you probably will notice is that PHP's start and end - tags have changed. The old <literal><? ></literal> form has been - replaced by three new possible forms: +<appendix id="migration"> + <title>PHP/FI 2.0 ìì PHP 3.0ë¡ ì´ì£¼</title> + <sect1 id="migration-about"> + <title>3.0ì ë¹íì±ì ëí´ì</title> + <simpara> + PHP 3.0ì ì²ìë¶í° ë¤ì ìì¬ì¡ë¤. + ê·¸ê²ì 2.0ì ë¹í´ í¨ì¬ë í¼í¼íê³ ì¼ê´ë íì(ëª ë ¹í´ì)ì ì í©íë¤. + 3.0ì ì´ë¯¸ ìë¹í 빨ë¼ì§ê³ , ëì± ì ì ë©ëª¨ë¦¬ë¥¼ ì¬ì©íë¤. íì§ë§, + ì´ë¤ì í¥ìì ë ì´ì 구문과 í¨ìì í¸íì±ì ê°ë¥íê² íì§ ëª»íë¤. + </simpara> + <simpara> + 첨ë¶íìë©´, PHPê°ë°ìë¤ì 3.0ìì PHPì 구문과 ìë¯¸ì²´ê³ ì쪽 ë¤ ì 리를 ìëíê³ + ì´ê²ì ì½ê°ì ë¹í¸íì±ì ì¼ê¸°ìì¼°ë¤. ë©ë¦¬ë³´ìë©´ ì°ë¦° ê·¸ê²ì´ ë ëì ê²ì ìí ë³íë¤ì´ìë¤ê³ + 믿ëë¤. + </simpara> + <simpara> + ì´ë² ì¥ì ë¹ì ìê² ìë§ PHP/FI 2.0ì PHP 3.0ì¼ë¡ ê°ëì ë¹í¸íì±ì ìë´í ê²ì´ê³ , + ê·¸ê²ì í´ê²°íë ¤ë ë¹ì ì ëëë¤. + ìë¡ì´ 기ë¥ì íìê° ìë¤ë©´ ì¬ê¸°ì ì¸ê¸íì§ ìëë¤. + </simpara> + <simpara> + ë³í íë¡ê·¸ë¨ì ìëì¼ë¡ ë¹ì ì 구 PHP/FI 2.0 ì¤í¬ë¦½í¸ë¥¼ ë³íìì¼ì¤ë¤. + ì´ê²ì + PHP 3.0 ë°°í¬ë³¸ì ìë¸ëë í 리 <filename class="directory">convertor</filename>ìì ì°¾ì ì ìë¤. + ì´ íë¡ê·¸ë¨ì ë¨ì§ 구문ì ì°¾ì ë°ê¾¸ë ê²ì´ê¸°ì ë¹ì ì ì´ì¨ë ì´ë² ì¥ì ì¡°ì¬ì¤ë ì½ì´ ëê°ì¼ í ê²ì´ë¤. + </simpara> + </sect1> + <sect1 id="migration-startendtags"> + <title>ìì/ë íê·¸ Start/end tags</title> + <para> + ë¹ì ìê² ìë§ ì£¼ìíë 첫ë²ì§¸ ê²ì PHPì ììê³¼ ëì´ ë°ëìë¤ë ê²ì´ë¤. + ìì ì <literal><? ></literal>ììì´ ì¸ê°ì§ ììì¼ë¡ ë°ëìë¤: <example> - <title>Migration: old start/end tags</title> - <programlisting> + <title>ì´ì£¼: ìì ìì/ë íê·¸</title> + <programlisting> <? echo "This is PHP/FI 2.0 code.\n"; > -</programlisting></example> - - As of version 2.0, PHP/FI also supports this variation: +</programlisting> + </example> +2.0ë²ì ìë, PHP/FI ë ì´ìê°ì ë³í를 ì§ìíê³ ììë¤. +As of version 2.0, PHP/FI also supports this variation: - <example><title>Migration: first new start/end tags</title> - <programlisting> + <example> + <title>ì´ì£¼: ìë¡ì´ 첫ë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <? echo "This is PHP 3.0 code!\n"; ?> -</programlisting></example> - - Notice that the end tag now consists of a question mark and a - greater-than character instead of just greater-than. However, if - you plan on using XML on your server, you will get problems with - the first new variant, because PHP may try to execute the XML - markup in XML documents as PHP code. Because of this, the - following variation was introduced: - - <example><title>Migration: second new start/end tags</title> - <programlisting> +</programlisting> + </example> +ì´ê²ì ë쪽 íê·¸ê° íëì ë¹êµë¬¸ìëì ì 물ìí ë§í¬ì ë¹êµë¬¸ìë¡ ì´ë£¨ì¡ë¤ë ê²ì ìì ìë¤. +ìë§ ë¹ì ì´ ë¹ì ì ìë²ì XML를 ì°ê¸°ë¥¼ ê³ííë¤ë©´ ì´ ìë¡ì´ ë³íë ëªëª 문ì ì ë¤ì ê°ì§ê³ ìë¤. +ìëíë©´ PHPë ìë§ XML문ììì XMLë§í¬ì ì PHPì½ëì²ë¼ ì¤íí ê²ì´ë¤. +ì´ê² ë문ì ë¤ìê³¼ ê°ì´ ìê°íë ê²ì ë°ë¥¸ë¤: + <example> + <title>ì´ì£¼: ìë¡ì´ ëë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <?php echo "This is PHP 3.0 code!\n"; ?> -</programlisting></example> - - Some people have had problems with editors that don't understand - the processing instruction tags at all. Microsoft FrontPage is one - such editor, and as a workaround for these, the following variation - was introduced as well: +</programlisting> + </example> - <example><title>Migration: third new start/end tags</title> - <programlisting> +ëªëª ì¬ëì ìëí°ë¤ì´ ì²ë¦¬êµ¬ë¬¸íê·¸ë¤ì ì¸ìíì§ ëª»íë 문ì 를 ê°ì§ê³ ììë¤. +ë§ì´í¬ë¡ìíí¸ íë¡ í¸íì´ì§ë ê·¸ë¬í ìëí°ë¤ì¤ íë ìê³ , +ë¤ìê³¼ ê°ì´ ìê°íë ë³í를 ë°ë¥¸ë¤: + <example> + <title>ì´ì£¼: ìë¡ì´ ì¸ë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <script language="php"> echo "This is PHP 3.0 code!\n"; </script> -</programlisting></example></para></sect1> - - - <sect1 id="migration-if-endif"> - <title>if..endif syntax</title> - - <para> - The `alternative' way to write if/elseif/else statements, using if(); - elseif(); else; endif; cannot be efficiently implemented without - adding a large amount of complexity to the 3.0 parser. Because of - this, the syntax has been changed: +</programlisting> + </example> + </para> + </sect1> + <sect1 id="migration-if-endif"> + <title>if..endif 구문</title> + <para> + 'ì íì ì¸'ë°©ë² if/elseif/elseííì ì¸ì ìê³ , if(); elseif(); else; endif();ì ì¬ì©ì + ë§ì ìì ë³µì¡í¨ì 3.0 íìì ì¶ê°ìì´ í¨ê³¼ì ì¸ ë구를 ì¬ì©í ì ìë¤ + ê·¸ë¬í기 ë문ì êµ¬ë¬¸ì´ ë°ëìë¤: <example> - <title>Migration: old if..endif syntax</title> - <programlisting> + <title>ì´ì£¼: ìì ì if..endif 구문</title> + <programlisting> if ($foo); echo "yep\n"; elseif ($bar); @@ -93,10 +87,11 @@ else; echo "nope\n"; endif; -</programlisting></example> - <example> - <title>Migration: new if..endif syntax</title> - <programlisting> +</programlisting> + </example> + <example> + <title>ì´ì£¼: ìë¡ì´ if..endif 구문</title> + <programlisting> if ($foo): echo "yep\n"; elseif ($bar): @@ -104,48 +99,49 @@ else: echo "nope\n"; endif; -</programlisting></example> - - Notice that the semicolons have been replaced by colons in all - statements but the one terminating the expression (endif).</para></sect1> - - <sect1 id="migration-while"> - <title>while syntax</title> - <para> - Just like with if..endif, the syntax of while..endwhile has changed - as well: - <example><title>Migration: old while..endwhile syntax</title> - <programlisting> +</programlisting> + </example> + ì¸ë¯¸ì½ë¡ ì 모ë ííìì ì½ë¡ ì¼ë¡ ë°ëìì¼ë ííììì íë²ì ì¢ ê²°ë¨ì 주목íë¼. (endif). +</para> + </sect1> + <sect1 id="migration-while"> + <title>while 구문</title> + <para> + if..endifì ê°ì´ while..endwhileì ë°ëìë¤: + <example> + <title>ì´ì£¼: ìì ì while..endwhile 구문</title> + <programlisting> while ($more_to_come); ... endwhile; -</programlisting></example> - <example><title>Migration: new while..endwhile syntax</title> - <programlisting> +</programlisting> + </example> + <example> + <title>ì´ì£¼: ìë¡ì´ while..endwhile 구문</title> + <programlisting> while ($more_to_come): ... endwhile; -</programlisting></example> - </para> - <warning> - <simpara> - If you use the old while..endwhile syntax in PHP 3.0, you will get - a never-ending loop. +</programlisting> + </example> + </para> + <warning> + <simpara> + ë¹ì ì´ ìì ì while..endwhile구문ì PHP 3.0ìì ì¬ì©íë¤ë©´ 무í루í를 íê² ë ê²ì´ë¤. </simpara> - </warning></sect1> - - <sect1 id="migration-expr"> - <title>Expression types</title> - <simpara> - PHP/FI 2.0 used the left side of expressions to determine what type - the result should be. PHP 3.0 takes both sides into account when - determining result types, and this may cause 2.0 scripts to behave - unexpectedly in 3.0.</simpara> - <simpara></simpara> - - <para> - Consider this example: - <informalexample><programlisting> + </warning> + </sect1> + <sect1 id="migration-expr"> + <title>ííì íì </title> + <simpara> + PHP/FI 2.0ì ì¼ìª½ì ê²°ê³¼ íì ì íì íë ííìì ì¬ì©íë¤ +used the left side of expressions to determine what type +PHP 3.0ì ê²°ê³¼ íì ì ê²°ì í ë ê³ì ì¼ë¡ë¶í° ì쪽ì ë°ëë¤. ê·¸ë¦¬ê³ ìë§ 2.0 ì¤í¬ë¦½í¸ì¸í´ 3.0ììë ë»ë°ì ë°ìì ê°ì§ê² ë ê²ì´ë¤.</simpara> + <simpara/> + <para> +ì´ ìì 를 ê²í íë¼: + <informalexample> + <programlisting> $a[0]=5; $a[1]=7; @@ -154,154 +150,141 @@ echo "$keyn"; next($a); } -</programlisting></informalexample> - - In PHP/FI 2.0, this would display both of $a's indices. In PHP - 3.0, it wouldn't display anything. The reason is that in PHP 2.0, - because the left argument's type was string, a string comparison - was made, and indeed <literal>""</literal> does not equal - <literal>"0"</literal>, and the loop went through. In PHP 3.0, - when a string is compared with an integer, an integer comparison is - made (the string is converted to an integer). This results in - comparing <literal>atoi("")</literal> which is - <literal>0</literal>, and <literal>variablelist</literal> which is - also <literal>0</literal>, and since <literal>0==0</literal>, the - loop doesn't go through even once. - - </para> - <para> - The fix for this is simple. Replace the while statement with: - <informalexample><programlisting> +</programlisting> + </informalexample> +PHP/FI 2.0ììë $aì ì¸ë±ì¤ ìì ì쪽 모ë ë³´ì¬ì¤ë¤. +PHP 3.0ììë ì무ê²ë ë³´ì¬ì£¼ì§ ìëë¤. +ê·¸ ì´ì ë PHP2.0ì ìë¤ +ì¼ìª½ ì¸ìì íì ì´ ë¬¸ìì´ë¹êµë¥¼ ìí´ ë§ë¤ì´ì§ 문ìì´ì´ê³ , ì¤ì <literal>""</literal>ê³¼ "0"ë 루í를 íµíë ëì ê°ì§ ìë¤, +PHP 3.0ììë 문ìì´ì´ ì ìë¹êµë¥¼ ìí´ ë§ë¤ì´ì§ ì ìì ë¹êµë ë (문ìì´ì ì ìë¡ ë³íëë¤), +<literal>atoi("")</literal> ë¹êµì ê²°ê³¼ë 0 ê³¼ <literal>variablelist</literal>, 0 ê³¼ <literal>0==0</literal> ì´í, +루íë íë²ë íµíì§ ëª»íë¤. +</para> + <para> +ê°ë¨íê² while구문ì ë°ê¿ì¼ë¡ì¨ ê³ ì³¤ë¤: + <informalexample> + <programlisting> while ((string)$key != "") { -</programlisting></informalexample></para></sect1> - - - <sect1 id="migration-errors"> - <title>Error messages have changed</title> - <simpara> - PHP 3.0's error messages are usually more accurate than 2.0's were, - but you no longer get to see the code fragment causing the error. - You will be supplied with a file name and a line number for the - error, though. - </simpara></sect1> - - - <sect1 id="migration-booleval"> - <title>Short-circuited boolean evaluation</title> - <simpara> - In PHP 3.0 boolean evaluation is short-circuited. This means that - in an expression like <literal>(1 || test_me())</literal>, the - function <function>test_me</function> would not be executed since - nothing can change the result of the expression after the - <literal>1</literal>.</simpara> - - <simpara> - This is a minor compatibility issue, but may cause unexpected - side-effects.</simpara></sect1> - - - <sect1 id="migration-truefalse"> - <title>Function true/false return values</title> - <simpara> - Most internal functions have been rewritten so they return TRUE - when successful and FALSE when failing, as opposed to 0 and -1 in - PHP/FI 2.0, respectively. The new behaviour allows for more - logical code, like <literal>$fp = fopen("/your/file") or - fail("darn!");</literal>. Because PHP/FI 2.0 had no clear rules - for what functions should return when they failed, most such - scripts will probably have to be checked manually after using the - 2.0 to 3.0 convertor.</simpara> - <para> - <example> - <title>Migration from 2.0: return values, old code</title> - <programlisting> +</programlisting> + </informalexample> + </para> + </sect1> + <sect1 id="migration-errors"> + <title>ì¤ë¥ ë©ì¸ì§ë¥¼ ë°ê¿¨ë¤.</title> + <simpara> + PHP3.0ì ì¤ë¥ ë©ì¸ì§ë 2.0ë³´ë¤ ë ì ì©íê² ì íí´ì¡ë¤. ê·¸ë¬ë, + ë¹ì ì ìë¬ë¡ ì¸í ì½ëì 깨ì§ì ë ì´ì ë°ì ë³¼ ì ìë¤. + ë¤ë§ ë¹ì ì ì¤ë¥ë¥¼ ìí íì¼ëª ê³¼ ì¤ë²í¸ë¥¼ ì ê³µë°ì ê²ì´ë¤. + </simpara> + </sect1> + <sect1 id="migration-booleval"> + <title>ë¨ë½ë ë¶ë¦° íê° + Short-circuited boolean evaluation</title> + <simpara> + PHP 3.0ì ë¶ë¦° íê°ë ë¨ë½ëìë¤. ì´ ë»ì <literal>(1 || test_me())</literal>ê°ì ííììì <function>test_me</function>í¨ìë <literal>1</literal>ì´í ííì ê²°ê³¼ì ë°ê¾¸ì§ ìë í ì¤íëì§ ìëë¤. +</simpara> + <simpara> + ì´ê±´ ì¤ìíì§ ìë í¸íì± ì´ìì´ë, ë¤ë¥¸ 쪽ì ìê¸°ì¹ ëª»íê² ìí¥ì ì¤ ì ìë¤. + </simpara> + </sect1> + <sect1 id="migration-truefalse"> + <title>í¨ì 리í´ê° true/false/title</title> + <simpara> + PHP/FI 2.0ì ê°ê° ë°ëëë 0ê³¼ -1ì²ë¼ ëë¶ë¶ì ë´ì¥ í¨ìë¤ì + trueì ì±ê³µì ì¼ë falseë ì¤í¨íìë 리í´ê°ì 주ëë¡ ë¤ì ìì¬ì¡ë¤. + ìë¡ì´ íëìë <literal>$fp = fopen("/your/file") or fail("darn!");</literal>ê°ì ë ë§ì ë ¼ë¦¬ì ì½ë를 íë½íë¤. + í¨ìê° ë¦¬í´ê°ì ì ëë¡ ëê¸°ì§ ëª»í ë PHP/FI 2.0ì ëì´ì 깨ëí ê·ì¹ì´ ìëë¤. + ëë¶ë¶ì ê·¸ë¬í ì¤í¬ë¦½í¸ë 2.0ìì 3.0ì ë³íì´í ìë§ ììì ì¼ë¡ ì ê²í´ì¼ íë¤. + </simpara> + <para> + <example> + <title>2.0ìì ì´ì£¼: 리í´ê°, ìì ì ì½ë</title> + <programlisting> $fp = fopen($file, "r"); if ($fp == -1); echo("Could not open $file for reading<br>\n"); endif; </programlisting> - </example> - <example> - <title>Migration from 2.0: return values, new code</title> - <programlisting> + </example> + <example> + <title>2.0ìì ì´ì£¼: 리í´ê°, ìë¡ì´ ì½ë</title> + <programlisting> $fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n"); </programlisting> - </example></para></sect1> - - - <sect1 id="migration-other"> - <title>Other incompatibilities</title> - - <itemizedlist> - <listitem><simpara> - The PHP 3.0 Apache module no longer supports Apache versions - prior to 1.2. Apache 1.2 or later is required.</simpara></listitem> - - <listitem><simpara> <function>echo</function> no longer - supports a format string. Use the - <function>printf</function> function instead.</simpara></listitem> - - <listitem><simpara> - In PHP/FI 2.0, an implementation side-effect caused - <literal>$foo[0]</literal> to have the same effect as - <literal>$foo</literal>. This is not true for PHP 3.0.</simpara></listitem> - - <listitem><simpara> - Reading arrays with <literal>$array[]</literal> is no longer - supported</simpara> - - <simpara> - That is, you cannot traverse an array by having a loop that does - <literal>$data = $array[]</literal>. Use - <function>current</function> and <function>next</function> - instead.</simpara> - <simpara> - Also, <literal>$array1[] = $array2</literal> does not append the - values of <literal>$array2</literal> to <literal>$array1</literal>, - but appends <literal>$array2</literal> as the last entry of - <literal>$array1</literal>. See also multidimensional array - support.</simpara></listitem> - - <listitem> - <simpara> <literal>"+"</literal> is no longer overloaded as a - concatenation operator for strings, instead it converts it's - arguments to numbers and performs numeric addition. Use - <literal>"."</literal> instead.</simpara></listitem> - </itemizedlist> - - <example> - <title>Migration from 2.0: concatenation for strings</title> - <programlisting> + </example> + </para> + </sect1> + <sect1 id="migration-other"> + <title>ê·¸ë°ì ë¹í¸íì±ë¤</title> + <itemizedlist> + <listitem> + <simpara> + PHP 3.0 ìíì¹ ëª¨ëì ëì´ì ìíì¹ 1.2ì´ì ë²ì ì ì§ìíì§ ìëë¤. + 1.2ë ê·¸ ì´í를 ì구íë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <function>echo</function>ë ëì´ì ììíë 문ìì´ì ì§ìíì§ ìëë¤. + ëì ì <function>printf</function>ì ì¬ì©íë¼.</simpara> + </listitem> + <listitem> + <simpara> + PHP/FI 2.0ììë <literal>$foo[0]</literal>ê³¼ <literal>$foo</literal>ë + ê°ì í¨ê³¼ë¥¼ ë¤ë¥¸ 쪽ìì ìííìë¤. PHP 3.0ìì ì´ê²ì ìíëì§ ìëë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <literal>$array[]</literal>ê°ì ë°°ì´ ì½ê¸°ë ëì´ì ì§ìíì§ ìëë¤. + </simpara> + <simpara> + ê·¸ê²ì ëì´ì ë¹ì ì´ ë£¨í를 ì´ì©í <literal>$data = $array[]</literal>ê°ì + ë°°ì´ ë기기를 í ì ìë¤. + ëì <function>current</function>ê³¼ <function>next</function>ì ì¬ì©íë¼. + </simpara> + <simpara> + ë§ì°¬ê°ì§ë¡ <literal>$array1[] = $array2</literal>ì <literal>$array2</literal>ì + <literal>$array1</literal>ì ê°ê³¼ ê°ì§ ìì§ë§, <literal>$array2</literal>ë + <literal>$array1</literal>ì ë§ì§ë§ ììì ê°ë¤. ì´ê²ì ë¤ì°¨ì ë°°ì´ë ë§ì°¬ê°ì§ë¡ + ì§ìíë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <literal>"+"</literal>ì ëì´ì 문ìì´ì ì°ê²°ìê° ìëë¤, ëì ê·¸ê²ì ì«ì ì¸ìì + ì«ìì ë§ì ì¼ë¡ ë°ëìë¤. ëì <literal>"."</literal>를 ì¬ì©íë¼. + </simpara> + </listitem> + </itemizedlist> + <example> + <title>2.0ìì ì´ì£¼: 문ìì´ ì°ê²°</title> + <programlisting> echo "1" + "1"; </programlisting> - - <para> - In PHP 2.0 this would echo 11, in PHP 3.0 it would echo 2. Instead - use: - - <programlisting> + <para> + PHP 2.0ììë 11ë¡ ì¶ë ¥ëì§ë§, 3.0ììë 2ë¡ ì¶ë ¥ëë¤. ëì²´íìë©´: +<programlisting> echo "1"."1"; </programlisting> - - <programlisting> +<programlisting> $a = 1; $b = 1; echo $a + $b; -</programlisting></para> - - <para> - This would echo 2 in both PHP 2.0 and 3.0. +</programlisting> + </para> + <para> + 2.0ê³¼ 3.0 모ëë¤ 2ê° ì¶ë ¥ëë¤. <programlisting> $a = 1; $b = 1; echo $a.$b; </programlisting> - This will echo 11 in PHP 3.0.</para> - </example></sect1> - - </appendix> - + 3.0ììë 11ì´ ì¶ë ¥ëë¤.</para> + </example> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml Index: phpdoc/kr/appendices/phpdevel.xml diff -u phpdoc/kr/appendices/phpdevel.xml:1.2 phpdoc/kr/appendices/phpdevel.xml:1.3 --- phpdoc/kr/appendices/phpdevel.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/phpdevel.xml Thu Jan 11 20:10:47 2001 @@ -1,71 +1,66 @@ -<appendix id="phpdevel"> - <title>PHP development</title> - - <simpara></simpara> - - <sect1 id="phpdevel-addfunc"> - <title>Adding functions to PHP 3</title> - <sect2 id="phpdevel-addfunc-prototype"> - <title>Function Prototype</title> - <para> - All functions look like this: +<appendix id="phpdevel"> + <title>PHP ê°ë°</title> + <simpara/> + <sect1 id="phpdevel-addfunc"> + <title>PHP 3ì í¨ì ì¶ê°</title> + <sect2 id="phpdevel-addfunc-prototype"> + <title>í¨ì í본</title> + <para> +모ë í¨ìë ë¤ìê³¼ ê°ë¤: <programlisting> void php3_foo(INTERNAL_FUNCTION_PARAMETERS) { } </programlisting> - Even if your function doesn't take any arguments, this is how it is - called.</para></sect2> +ë¹ë¡ í¨ìê° ì´ë¤ ì¸ìë ê°ì§ ìëë¼ë í¨ìë¼ ì¹íë¤. +</para> + </sect2> + <sect2 id="phpdevel-addfunc-args"> + <title>í¨ì ì¸ì</title> + <para> - <sect2 id="phpdevel-addfunc-args"> - <title>Function Arguments</title> - <para> Arguments are always of type pval. This type contains a union which has the actual type of the argument. So, if your function takes two arguments, you would do something like the following at the top of your function:</para> - - <para> - <example> - <title>Fetching function arguments</title> - <programlisting> + <para> + <example> + <title>Fetching function arguments</title> + <programlisting> pval *arg1, *arg2; if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&arg1,&arg2)==FAILURE) { WRONG_PARAM_COUNT; } </programlisting> - </example> + </example> NOTE: Arguments can be passed either by value or by reference. In both cases you will need to pass &(pval *) to getParameters. If you want to check if the n'th parameter was sent to you by reference or not, you can use the function, ParameterPassedByReference(ht,n). It will return either 1 or 0.</para> - - <simpara> + <simpara> When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over with the parameter by calling pval_destructor on it, or if it's an ARRAY you want to add to, you can use functions similar to the ones in internal_functions.h which manipulate return_value as an ARRAY.</simpara> - - <simpara> + <simpara> Also if you change a parameter to IS_STRING make sure you first assign the new estrdup()'ed string and the string length, and only later change the type to IS_STRING. If you change the string of a parameter which already IS_STRING or IS_ARRAY you should run - pval_destructor on it first.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-varargs"> - <title>Variable Function Arguments</title> - <para> + pval_destructor on it first.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-varargs"> + <title>Variable Function Arguments</title> + <para> A function can take a variable number of arguments. If your function can take either 2 or 3 arguments, use the following:</para> - - <para> - <example> - <title>Variable function arguments</title> - <programlisting> + <para> + <example> + <title>Variable function arguments</title> + <programlisting> pval *arg1, *arg2, *arg3; int arg_count = ARG_COUNT(ht); @@ -74,59 +69,60 @@ WRONG_PARAM_COUNT; } </programlisting> - </example></para></sect2> - - <sect2 id="phpdevel-addfunc-using-args"> - <title>Using the Function Arguments</title> - <para> + </example> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-using-args"> + <title>Using the Function Arguments</title> + <para> The type of each argument is stored in the pval type field. This type can be any of the following: <table> - <title>PHP Internal Types</title> - <tgroup cols="2"> - <tbody> - <row> - <entry>IS_STRING</entry> - <entry>String</entry> - </row> - <row> - <entry>IS_DOUBLE</entry> - <entry>Double-precision floating point</entry> - </row> - <row> - <entry>IS_LONG</entry> - <entry>Long integer</entry> - </row> - <row> - <entry>IS_ARRAY</entry> - <entry>Array</entry> - </row> - <row> - <entry>IS_EMPTY</entry> - <entry>None</entry> - </row> - <row> - <entry>IS_USER_FUNCTION</entry> - <entry>??</entry> - </row> - <row> - <entry>IS_INTERNAL_FUNCTION</entry> - <entry>?? (if some of these cannot be passed to a function - delete)</entry> - </row> - <row> - <entry>IS_CLASS</entry> - <entry>??</entry> - </row> - <row> - <entry>IS_OBJECT</entry> - <entry>??</entry> - </row> - </tbody> - </tgroup> - </table></para> - - <para> + <title>PHP Internal Types</title> + <tgroup cols="2"> + <tbody> + <row> + <entry>IS_STRING</entry> + <entry>String</entry> + </row> + <row> + <entry>IS_DOUBLE</entry> + <entry>Double-precision floating point</entry> + </row> + <row> + <entry>IS_LONG</entry> + <entry>Long integer</entry> + </row> + <row> + <entry>IS_ARRAY</entry> + <entry>Array</entry> + </row> + <row> + <entry>IS_EMPTY</entry> + <entry>None</entry> + </row> + <row> + <entry>IS_USER_FUNCTION</entry> + <entry>??</entry> + </row> + <row> + <entry>IS_INTERNAL_FUNCTION</entry> + <entry>?? (if some of these cannot be passed to a function - delete)</entry> + </row> + <row> + <entry>IS_CLASS</entry> + <entry>??</entry> + </row> + <row> + <entry>IS_OBJECT</entry> + <entry>??</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> If you get an argument of one type and would like to use it as another, or if you just want to force the argument to be of a certain type, you can use one of the following conversion @@ -138,28 +134,33 @@ convert_to_string(arg1); convert_to_boolean_long(arg1); /* If the string is "" or "0" it becomes 0, 1 otherwise */ convert_string_to_number(arg1); /* Converts string to either LONG or DOUBLE depending on string */ - </programlisting></para> - - <simpara> + </programlisting> + </para> + <simpara> These function all do in-place conversion. They do not return anything.</simpara> - - <para> + <para> The actual argument is stored in a union; the members are: <itemizedlist> - <listitem><simpara>IS_STRING: arg1->value.str.val</simpara></listitem> - <listitem><simpara>IS_LONG: arg1->value.lval</simpara></listitem> - <listitem><simpara>IS_DOUBLE: arg1->value.dval</simpara></listitem> - </itemizedlist></para></sect2> - - <sect2 id="phpdevel-addfunc-memmgmt"> - <title>Memory Management in Functions</title> - <simpara> + <listitem> + <simpara>IS_STRING: arg1->value.str.val</simpara> + </listitem> + <listitem> + <simpara>IS_LONG: arg1->value.lval</simpara> + </listitem> + <listitem> + <simpara>IS_DOUBLE: arg1->value.dval</simpara> + </listitem> + </itemizedlist> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-memmgmt"> + <title>Memory Management in Functions</title> + <simpara> Any memory needed by a function should be allocated with either emalloc() or estrdup(). These are memory handling abstraction functions that look and smell like the normal malloc() and strdup() functions. Memory should be freed with efree().</simpara> - - <simpara> + <simpara> There are two kinds of memory in this program: memory which is returned to the parser in a variable, and memory which you need for temporary storage in your internal function. When you assign a @@ -168,8 +169,7 @@ estrdup(). This memory should NEVER be freed by you, unless you later in the same function overwrite your original assignment (this kind of programming practice is not good though).</simpara> - - <simpara> + <simpara> For any temporary/permanent memory you need in your functions/library you should use the three emalloc(), estrdup(), and efree() functions. They behave EXACTLY like their counterpart @@ -179,99 +179,96 @@ leak. The meaning of "the functions behave exactly like their counterparts" is: if you efree() something which was not emalloc()'ed nor estrdup()'ed you might get a segmentation - fault. So please take care and free all of your wasted memory.</simpara> - - <simpara> + fault. So please take care and free all of your wasted memory.</simpara> + <simpara> If you compile with "-DDEBUG", PHP 3 will print out a list of all memory that was allocated using emalloc() and estrdup() but never - freed with efree() when it is done running the specified script.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-symtab"> - <title>Setting Variables in the Symbol Table</title> - <para> + freed with efree() when it is done running the specified script.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-symtab"> + <title>Setting Variables in the Symbol Table</title> + <para> A number of macros are available which make it easier to set a variable in the symbol table: <itemizedlist> - <listitem><simpara>SET_VAR_STRING(name,value) <footnoteref linkend="symtab-1"/></simpara></listitem> - <listitem><simpara>SET_VAR_DOUBLE(name,value)</simpara></listitem> - <listitem><simpara>SET_VAR_LONG(name,value)</simpara></listitem> - </itemizedlist></para> - - <para> - <footnote id="symtab-1"> - <simpara> + <listitem> + <simpara>SET_VAR_STRING(name,value) <footnoteref linkend="symtab-1"/> + </simpara> + </listitem> + <listitem> + <simpara>SET_VAR_DOUBLE(name,value)</simpara> + </listitem> + <listitem> + <simpara>SET_VAR_LONG(name,value)</simpara> + </listitem> + </itemizedlist> + </para> + <para> + <footnote id="symtab-1"> + <simpara> Be careful here. The value part must be malloc'ed manually because the memory management code will try to free this pointer later. Do not pass statically allocated memory into a SET_VAR_STRING.</simpara> - </footnote></para> - - <simpara> + </footnote> + </para> + <simpara> Symbol tables in PHP 3.0 are implemented as hash tables. At any given time, &symbol_table is a pointer to the 'main' symbol table, and active_symbol_table points to the currently active symbol table (these may be identical like in startup, or different, if you're inside a function).</simpara> - - <para> + <para> The following examples use 'active_symbol_table'. You should replace it with &symbol_table if you specifically want to work with the 'main' symbol table. Also, the same functions may be applied to arrays, as explained below.</para> - - <para> - <example> - <title>Checking whether $foo exists in a symbol table</title> - <programlisting> + <para> + <example> + <title>Checking whether $foo exists in a symbol table</title> + <programlisting> if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... } else { doesn't exist } </programlisting> - </example> - - <example> - <title>Finding a variable's size in a symbol table</title> - <programlisting> + </example> + <example> + <title>Finding a variable's size in a symbol table</title> + <programlisting> hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue); check(pvalue.type); </programlisting> - </example> + </example> Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can also be used to check variables inside arrays.</para> - - <simpara> + <simpara> If you want to define a new array in a symbol table, you should do the following.</simpara> - - <simpara> + <simpara> First, you may want to check whether it exists and abort appropiately, using hash_exists() or hash_find().</simpara> - - <simpara> + <simpara> Next, initialize the array:</simpara> - - <para> - <example> - <title>Initializing a new array</title> - <programlisting> + <para> + <example> + <title>Initializing a new array</title> + <programlisting> pval arr; if (array_init(&arr) == FAILURE) { failed... }; hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL); </programlisting> - </example> + </example> This code declares a new array, named $foo, in the active symbol table. This array is empty.</para> - - <simpara> + <simpara> Here's how to add new entries to it:</simpara> - - <para> - <example> - <title>Adding entries to a new array</title> - <programlisting> + <para> + <example> + <title>Adding entries to a new array</title> + <programlisting> pval entry; entry.type = IS_LONG; @@ -288,7 +285,7 @@ */ hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); </programlisting> - </example> + </example> If you'd like to modify a value that you inserted to a hash, you must first retrieve it from the hash. To prevent that overhead, @@ -296,29 +293,23 @@ updated with the pval * address of the inserted element inside the hash. If that value is NULL (like in all of the above examples) - that parameter is ignored.</para> - - <simpara> + <simpara> hash_next_index_insert() uses more or less the same logic as "$foo[] = bar;" in PHP 2.0.</simpara> - - <simpara> + <simpara> If you are building an array to return from a function, you can initialize the array just like above by doing:</simpara> - - <programlisting> + <programlisting> if (array_init(return_value) == FAILURE) { failed...; } </programlisting> - - <simpara> + <simpara> ...and then adding values with the helper functions:</simpara> - - <programlisting> + <programlisting> add_next_index_long(return_value,long_value); add_next_index_double(return_value,double_value); add_next_index_string(return_value,estrdup(string_value)); </programlisting> - - <para> + <para> Of course, if the adding isn't done right after the array initialization, you'd probably have to look for the array first: @@ -327,69 +318,96 @@ if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... } else { use arr->value.ht... } - </programlisting></para> - - <simpara> + </programlisting> + </para> + <simpara> Note that hash_find receives a pointer to a pval pointer, and not a pval pointer.</simpara> - - <simpara> + <simpara> Just about any hash function returns SUCCESS or FAILURE (except - for hash_exists(), which returns a boolean truth value).</simpara></sect2> - - <sect2 id="phpdevel-addfunc-retsimple"> - <title>Returning simple values</title> - <simpara> + for hash_exists(), which returns a boolean truth value).</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-retsimple"> + <title>Returning simple values</title> + <simpara> A number of macros are available to make returning values from a - function easier.</simpara> - - <para> + function easier.</simpara> + <para> The RETURN_* macros all set the return value and return from the function: <itemizedlist> - <listitem><simpara>RETURN</simpara></listitem> - <listitem><simpara>RETURN_FALSE</simpara></listitem> - <listitem><simpara>RETURN_TRUE</simpara></listitem> - <listitem><simpara>RETURN_LONG(l)</simpara></listitem> - <listitem><simpara>RETURN_STRING(s,dup) If dup is true, duplicates the string</simpara></listitem> - <listitem><simpara>RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara></listitem> - <listitem><simpara>RETURN_DOUBLE(d)</simpara></listitem> - </itemizedlist></para> - - <para> + <listitem> + <simpara>RETURN</simpara> + </listitem> + <listitem> + <simpara>RETURN_FALSE</simpara> + </listitem> + <listitem> + <simpara>RETURN_TRUE</simpara> + </listitem> + <listitem> + <simpara>RETURN_LONG(l)</simpara> + </listitem> + <listitem> + <simpara>RETURN_STRING(s,dup) If dup is true, duplicates the string</simpara> + </listitem> + <listitem> + <simpara>RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara> + </listitem> + <listitem> + <simpara>RETURN_DOUBLE(d)</simpara> + </listitem> + </itemizedlist> + </para> + <para> The RETVAL_* macros set the return value, but do not return. <itemizedlist> - <listitem><simpara>RETVAL_FALSE</simpara></listitem> - <listitem><simpara>RETVAL_TRUE</simpara></listitem> - <listitem><simpara>RETVAL_LONG(l)</simpara></listitem> - <listitem><simpara>RETVAL_STRING(s,dup) If dup is true, duplicates the string</simpara></listitem> - <listitem><simpara>RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara></listitem> - <listitem><simpara>RETVAL_DOUBLE(d)</simpara></listitem> - </itemizedlist></para> - - <simpara> + <listitem> + <simpara>RETVAL_FALSE</simpara> + </listitem> + <listitem> + <simpara>RETVAL_TRUE</simpara> + </listitem> + <listitem> + <simpara>RETVAL_LONG(l)</simpara> + </listitem> + <listitem> + <simpara>RETVAL_STRING(s,dup) If dup is true, duplicates the string</simpara> + </listitem> + <listitem> + <simpara>RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara> + </listitem> + <listitem> + <simpara>RETVAL_DOUBLE(d)</simpara> + </listitem> + </itemizedlist> + </para> + <simpara> The string macros above will all estrdup() the passed 's' argument, so you can safely free the argument after calling the macro, or alternatively use statically allocated memory.</simpara> - - <simpara> + <simpara> If your function returns boolean success/error responses, always - use RETURN_TRUE and RETURN_FALSE respectively.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-retcomplex"> - <title>Returning complex values</title> - <simpara> + use RETURN_TRUE and RETURN_FALSE respectively.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-retcomplex"> + <title>Returning complex values</title> + <simpara> Your function can also return a complex data type such as an object or an array.</simpara> - - <para> + <para> Returning an object: <orderedlist numeration="arabic"> - <listitem><simpara>Call object_init(return_value).</simpara></listitem> - <listitem><para>Fill it up with values. The functions available - for this purpose are listed below.</para></listitem> - <listitem><para> Possibly, register functions for this object. + <listitem> + <simpara>Call object_init(return_value).</simpara> + </listitem> + <listitem> + <para>Fill it up with values. The functions available + for this purpose are listed below.</para> + </listitem> + <listitem> + <para> Possibly, register functions for this object. In order to obtain values from the object, the function would have to fetch "this" from the active_symbol_table. Its type should be IS_OBJECT, and it's basically a regular hash table @@ -397,85 +415,127 @@ actual registration of the function can be done using: <programlisting> add_method( return_value, function_name, function_ptr ); - </programlisting></para></listitem> - </orderedlist></para> - - <para> + </programlisting> + </para> + </listitem> + </orderedlist> + </para> + <para> The functions used to populate an object are: <itemizedlist> - <listitem><simpara>add_property_long( return_value, + <listitem> + <simpara>add_property_long( return_value, property_name, l ) - Add a property named 'property_name', of - type long, equal to 'l'</simpara></listitem> - <listitem><simpara>add_property_double( return_value, - property_name, d ) - Same, only adds a double</simpara></listitem> - <listitem><simpara>add_property_string( return_value, - property_name, str ) - Same, only adds a string</simpara></listitem> - <listitem><simpara>add_property_stringl( return_value, - property_name, str, l ) - Same, only adds a string of length 'l'</simpara></listitem> - </itemizedlist></para> - - <para> + type long, equal to 'l'</simpara> + </listitem> + <listitem> + <simpara>add_property_double( return_value, + property_name, d ) - Same, only adds a double</simpara> + </listitem> + <listitem> + <simpara>add_property_string( return_value, + property_name, str ) - Same, only adds a string</simpara> + </listitem> + <listitem> + <simpara>add_property_stringl( return_value, + property_name, str, l ) - Same, only adds a string of length 'l'</simpara> + </listitem> + </itemizedlist> + </para> + <para> Returning an array: <orderedlist numeration="arabic"> - <listitem><simpara>Call array_init(return_value).</simpara></listitem> - <listitem><simpara>Fill it up with values. The functions available - for this purpose are listed below.</simpara></listitem> - </orderedlist></para> - - <para> + <listitem> + <simpara>Call array_init(return_value).</simpara> + </listitem> + <listitem> + <simpara>Fill it up with values. The functions available + for this purpose are listed below.</simpara> + </listitem> + </orderedlist> + </para> + <para> The functions used to populate an array are: <itemizedlist> - <listitem><simpara>add_assoc_long(return_value,key,l) - add - associative entry with key 'key' and long value 'l'</simpara></listitem> - <listitem><simpara>add_assoc_double(return_value,key,d)</simpara></listitem> - <listitem><simpara>add_assoc_string(return_value,key,str,duplicate)</simpara></listitem> - <listitem><simpara>add_assoc_stringl(return_value,key,str,length,duplicate) - specify the string length</simpara></listitem> - <listitem><simpara>add_index_long(return_value,index,l) - add - entry in index 'index' with long value 'l'</simpara></listitem> - <listitem><simpara>add_index_double(return_value,index,d)</simpara></listitem> - <listitem><simpara>add_index_string(return_value,index,str)</simpara></listitem> - <listitem><simpara>add_index_stringl(return_value,index,str,length) - - specify the string length</simpara></listitem> - <listitem><simpara>add_next_index_long(return_value,l) - add an - array entry in the next free offset with long value 'l'</simpara></listitem> - <listitem><simpara>add_next_index_double(return_value,d)</simpara></listitem> - <listitem><simpara>add_next_index_string(return_value,str)</simpara></listitem> - <listitem><simpara>add_next_index_stringl(return_value,str,length) - - specify the string length</simpara></listitem> - </itemizedlist></para></sect2> - - <sect2 id="phpdevel-addfunc-reslist"> - <title>Using the resource list</title> - <simpara> + <listitem> + <simpara>add_assoc_long(return_value,key,l) - add + associative entry with key 'key' and long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_assoc_double(return_value,key,d)</simpara> + </listitem> + <listitem> + <simpara>add_assoc_string(return_value,key,str,duplicate)</simpara> + </listitem> + <listitem> + <simpara>add_assoc_stringl(return_value,key,str,length,duplicate) + specify the string length</simpara> + </listitem> + <listitem> + <simpara>add_index_long(return_value,index,l) - add + entry in index 'index' with long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_index_double(return_value,index,d)</simpara> + </listitem> + <listitem> + <simpara>add_index_string(return_value,index,str)</simpara> + </listitem> + <listitem> + <simpara>add_index_stringl(return_value,index,str,length) + - specify the string length</simpara> + </listitem> + <listitem> + <simpara>add_next_index_long(return_value,l) - add an + array entry in the next free offset with long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_next_index_double(return_value,d)</simpara> + </listitem> + <listitem> + <simpara>add_next_index_string(return_value,str)</simpara> + </listitem> + <listitem> + <simpara>add_next_index_stringl(return_value,str,length) + - specify the string length</simpara> + </listitem> + </itemizedlist> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-reslist"> + <title>Using the resource list</title> + <simpara> PHP 3.0 has a standard way of dealing with various types of resources. This replaces all of the local linked lists in PHP 2.0.</simpara> - - <para> + <para> Available functions: <itemizedlist> - <listitem><simpara>php3_list_insert(ptr, type) - returns the 'id' - of the newly inserted resource</simpara></listitem> - <listitem><simpara>php3_list_delete(id) - delete the resource - with the specified id</simpara></listitem> - <listitem><simpara>php3_list_find(id,*type) + <listitem> + <simpara>php3_list_insert(ptr, type) - returns the 'id' + of the newly inserted resource</simpara> + </listitem> + <listitem> + <simpara>php3_list_delete(id) - delete the resource + with the specified id</simpara> + </listitem> + <listitem> + <simpara>php3_list_find(id,*type) - returns the pointer of the resource with the specified id, - updates 'type' to the resource's type</simpara></listitem> - </itemizedlist> + updates 'type' to the resource's type</simpara> + </listitem> + </itemizedlist> Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file descriptors.</para> - - <simpara> + <simpara> Typical list code would look like this:</simpara> - - <para> - <example> - <title>Adding a new resource</title> - <programlisting> + <para> + <example> + <title>Adding a new resource</title> + <programlisting> RESOURCE *resource; /* ...allocate memory for resource and acquire resource... */ @@ -483,11 +543,10 @@ return_value->value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE); return_value->type = IS_LONG; </programlisting> - </example> - - <example> - <title>Using an existing resource</title> - <programlisting> + </example> + <example> + <title>Using an existing resource</title> + <programlisting> pval *resource_id; RESOURCE *resource; int type; @@ -500,11 +559,10 @@ } /* ...use resource... */ </programlisting> - </example> - - <example> - <title>Deleting an existing resource</title> - <programlisting> + </example> + <example> + <title>Deleting an existing resource</title> + <programlisting> pval *resource_id; RESOURCE *resource; int type; @@ -512,17 +570,17 @@ convert_to_long(resource_id); php3_list_delete(resource_id->value.lval); </programlisting> - </example> + </example> The resource types should be registered in php3_list.h, in enum list_entry_type. In addition, one should add shutdown code for any new resource type defined, in list.c's list_entry_destructor() (even if you don't have anything to do on shutdown, you must add - an empty case).</para></sect2> - - <sect2 id="phpdevel-addfunc-prestable"> - <title>Using the persistent resource table</title> - <para> + an empty case).</para> + </sect2> + <sect2 id="phpdevel-addfunc-prestable"> + <title>Using the persistent resource table</title> + <para> PHP 3.0 has a standard way of storing persistent resources (i.e., resources that are kept in between hits). The first module to use this feature was the MySQL module, and mSQL followed it, so one @@ -530,17 +588,20 @@ be used by reading mysql.c. The functions you should look at are: <simplelist> - <member>php3_mysql_do_connect</member> - <member>php3_mysql_connect()</member> - <member>php3_mysql_pconnect()</member> - </simplelist></para> - - <para> + <member>php3_mysql_do_connect</member> + <member>php3_mysql_connect()</member> + <member>php3_mysql_pconnect()</member> + </simplelist> + </para> + <para> The general idea of persistence modules is this: <orderedlist numeration="arabic"> - <listitem><simpara>Code all of your module to work with the - regular resource list mentioned in section (9).</simpara></listitem> - <listitem><simpara>Code extra connect functions that check if the + <listitem> + <simpara>Code all of your module to work with the + regular resource list mentioned in section (9).</simpara> + </listitem> + <listitem> + <simpara>Code extra connect functions that check if the resource already exists in the persistent resource list. If it does, register it as in the regular resource list as a pointer to the persistent resource list (because of 1., the rest of the code @@ -551,30 +612,34 @@ resource would be found in the persistent resource list and be used without having to recreate it. You should register these resources with a different type (e.g. LE_MYSQL_LINK for - non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara></listitem> - </orderedlist></para> - - <simpara> + non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara> + </listitem> + </orderedlist> + </para> + <simpara> If you read mysql.c, you'll notice that except for the more complex connect function, nothing in the rest of the module has to be changed.</simpara> - - <simpara> + <simpara> The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with 'plist':</simpara> - - <itemizedlist> - <listitem><simpara>php3_plist_insert(ptr, type) - returns the 'id' - of the newly inserted resource</simpara></listitem> - <listitem><simpara>php3_plist_delete(id) - delete the resource - with the specified id</simpara></listitem> - <listitem><simpara>php3_plist_find(id,*type) + <itemizedlist> + <listitem> + <simpara>php3_plist_insert(ptr, type) - returns the 'id' + of the newly inserted resource</simpara> + </listitem> + <listitem> + <simpara>php3_plist_delete(id) - delete the resource + with the specified id</simpara> + </listitem> + <listitem> + <simpara>php3_plist_find(id,*type) - returns the pointer of the resource with the specified id, - updates 'type' to the resource's type</simpara></listitem> - </itemizedlist> - - <simpara> + updates 'type' to the resource's type</simpara> + </listitem> + </itemizedlist> + <simpara> However, it's more than likely that these functions would prove to be useless for you when trying to implement a persistent module. Typically, one would want to use the fact that the persistent @@ -585,12 +650,10 @@ this string as a key. The next time someone calls a pconnect() with the same host/user/passwd, the same key would be generated, and the function would find the SQL link in the persistent list.</simpara> - - <simpara> + <simpara> Until further documented, you should look at mysql.c or msql.c to see how one should use the plist's hash table abilities.</simpara> - - <simpara> + <simpara> One important thing to note: resources going into the persistent resource list must *NOT* be allocated with PHP's memory manager, i.e., they should NOT be created with emalloc(), estrdup(), etc. @@ -600,8 +663,7 @@ manager is deleted. Since the persistent list isn't supposed to be erased at the end of a request, one mustn't use PHP's memory manager for allocating resources that go to it.</simpara> - - <simpara> + <simpara> When you register a resource that's going to be in the persistent list, you should add destructors to it both in the non-persistent list and in the persistent list. The destructor in the @@ -612,12 +674,11 @@ every resource, even it requires no destructotion and the destructor would be empty. Remember, since emalloc() and friends aren't to be used in conjunction with the persistent list, you - mustn't use efree() here either.</simpara></sect2> - - - <sect2 id="phpdevel-addfunc-addcfg"> - <title>Adding runtime configuration directives</title> - <para> + mustn't use efree() here either.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-addcfg"> + <title>Adding runtime configuration directives</title> + <para> Many of the features of PHP 3 can be configured at runtime. These configuration directives can appear in either the designated php3.ini file, or in the case of the Apache module version in the @@ -627,73 +688,75 @@ safemodeexecdir for example, while another directory may have another. This configuration granularity is especially handy when a server supports multiple virtual hosts.</para> - - <para> + <para> The steps required to add a new directive: <orderedlist> - <listitem><simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara></listitem> - - <listitem><simpara>In main.c, edit the php3_module_startup + <listitem> + <simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara> + </listitem> + <listitem> + <simpara>In main.c, edit the php3_module_startup function and add the appropriate cfg_get_string() or - cfg_get_long() call.</simpara></listitem> - - <listitem><simpara>Add the directive, restrictions and a comment + cfg_get_long() call.</simpara> + </listitem> + <listitem> + <simpara>Add the directive, restrictions and a comment to the php3_commands structure in mod_php3.c. Note the restrictions part. RSRC_CONF are directives that can only be present in the actual Apache .conf files. Any OR_OPTIONS directives can be present anywhere, include normal .htaccess - files.</simpara></listitem> - - <listitem><simpara>In either php3take1handler() or - php3flaghandler() add the appropriate entry for your directive.</simpara></listitem> - - <listitem><simpara>In the configuration section of the + files.</simpara> + </listitem> + <listitem> + <simpara>In either php3take1handler() or + php3flaghandler() add the appropriate entry for your directive.</simpara> + </listitem> + <listitem> + <simpara>In the configuration section of the _php3_info() function in functions/info.c you need to add your - new directive.</simpara></listitem> - - <listitem><simpara>And last, you of course have to use your new + new directive.</simpara> + </listitem> + <listitem> + <simpara>And last, you of course have to use your new directive somewhere. It will be addressable as - php3_ini.directive.</simpara></listitem> - </orderedlist></para></sect2></sect1> - - - <sect1 id="calling-user-functions"> - <title>Calling User Functions</title> - - <simpara> + php3_ini.directive.</simpara> + </listitem> + </orderedlist> + </para> + </sect2> + </sect1> + <sect1 id="calling-user-functions"> + <title>Calling User Functions</title> + <simpara> To call user functions from an internal function, you should use the <function>call_user_function</function> function. </simpara> - - <simpara> - <function>call_user_function</function> returns SUCCESS on success, + <simpara> + <function>call_user_function</function> returns SUCCESS on success, and FAILURE in case the function cannot be found. You should check that return value! If it returns SUCCESS, you are responsible for destroying the retval pval yourself (or return it as the return value of your function). If it returns FAILURE, the value of retval is undefined, and you mustn't touch it. </simpara> - - <simpara> + <simpara> All internal functions that call user functions <emphasis>must</emphasis> be reentrant. Among other things, this means they must not use globals or static variables. </simpara> - - <simpara> - <function>call_user_function</function> takes six arguments: + <simpara> + <function>call_user_function</function> takes six arguments: </simpara> - - <sect2 id="calling-user-functions.function-table"> - <title>HashTable *function_table</title> - <simpara> + <sect2 id="calling-user-functions.function-table"> + <title>HashTable *function_table</title> + <simpara> This is the hash table in which the function is to be looked up. - </simpara></sect2> - - <sect2 id="calling-user-functions.object"> - <title>pval *object</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.object"> + <title>pval *object</title> + <simpara> This is a pointer to an object on which the function is invoked. This should be NULL if a global function is called. If it's not NULL (i.e. it points to an object), the function_table argument is @@ -701,48 +764,48 @@ be modified by the function that is invoked on it (that function will have access to it via $this). If for some reason you don't want that to happen, send a copy of the object instead. - </simpara></sect2> - - <sect2 id="calling-user-functions.function-name"> - <title>pval *function_name</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.function-name"> + <title>pval *function_name</title> + <simpara> The name of the function to call. Must be a pval of type IS_STRING with function_name.str.val and function_name.str.len set to the appropriate values. The function_name is modified by call_user_function() - it's converted to lowercase. If you need to preserve the case, send a copy of the function name instead. - </simpara></sect2> - - <sect2 id="calling-user-functions.retval"> - <title>pval *retval</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.retval"> + <title>pval *retval</title> + <simpara> A pointer to a pval structure, into which the return value of the invoked function is saved. The structure must be previously allocated - <function>call_user_function</function> does NOT allocate it by itself. - </simpara></sect2> - - <sect2 id="calling-user-functions.param-count"> - <title>int param_count</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.param-count"> + <title>int param_count</title> + <simpara> The number of parameters being passed to the function. - </simpara></sect2> - - <sect2 id="calling-user-functions.params"> - <title>pval *params[]</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.params"> + <title>pval *params[]</title> + <simpara> An array of pointers to values that will be passed as arguments to the function, the first argument being in offset 0, the second in offset 1, etc. The array is an array of pointers to pval's; The pointers are sent as-is to the function, which means if the function modifies its arguments, the original values are changed (passing by reference). If you don't want that behavior, pass a copy instead. - </simpara></sect2></sect1> - - <sect1 id="phpdevel-errors"> - <title>Reporting Errors</title> - - <simpara> + </simpara> + </sect2> + </sect1> + <sect1 id="phpdevel-errors"> + <title>Reporting Errors</title> + <simpara> To report errors from an internal function, you should call the <function>php3_error</function> function. This takes at least two parameters -- the first is the level of the error, the second is @@ -750,106 +813,94 @@ <function>printf</function> call), and any following arguments are the parameters for the format string. The error levels are: </simpara> - - <sect2 id="internal.e-notice"> - <title>E_NOTICE</title> - <simpara> + <sect2 id="internal.e-notice"> + <title>E_NOTICE</title> + <simpara> Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. For example, trying to access the value of a variable which has not been set, or calling <function>stat</function> on a file that doesn't exist. </simpara> - </sect2> - - <sect2 id="internal.e-warning"> - <title>E_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-warning"> + <title>E_WARNING</title> + <simpara> Warnings are printed by default, but do not interrupt script execution. These indicate a problem that should have been trapped by the script before the call was made. For example, calling <function>ereg</function> with an invalid regular expression. </simpara> - </sect2> - - <sect2 id="internal.e-error"> - <title>E_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-error"> + <title>E_ERROR</title> + <simpara> Errors are also printed by default, and execution of the script is halted after the function returns. These indicate errors that can not be recovered from, such as a memory allocation problem. </simpara> - </sect2> - - <sect2 id="internal.e-parse"> - <title>E_PARSE</title> - <simpara> + </sect2> + <sect2 id="internal.e-parse"> + <title>E_PARSE</title> + <simpara> Parse errors should only be generated by the parser. The code is listed here only for the sake of completeness. </simpara> - </sect2> - - <sect2 id="internal.e-core-error"> - <title>E_CORE_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-core-error"> + <title>E_CORE_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated by the core of PHP. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-core-warning"> - <title>E_CORE_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-core-warning"> + <title>E_CORE_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by the core of PHP. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-compile-error"> - <title>E_COMPILE_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-compile-error"> + <title>E_COMPILE_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-compile-warning"> - <title>E_COMPILE_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-compile-warning"> + <title>E_COMPILE_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-error"> - <title>E_USER_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-error"> + <title>E_USER_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated in PHP code by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-warning"> - <title>E_USER_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-warning"> + <title>E_USER_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-notice"> - <title>E_USER_NOTICE</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-notice"> + <title>E_USER_NOTICE</title> + <simpara> This is like an E_NOTICE, except it is generated by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - </sect1> - </appendix> + </sect2> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml
Index: phpdoc/kr/appendices/debugger.xml diff -u phpdoc/kr/appendices/debugger.xml:1.2 phpdoc/kr/appendices/debugger.xml:1.3 --- phpdoc/kr/appendices/debugger.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/debugger.xml Thu Jan 11 20:10:47 2001 @@ -1,10 +1,8 @@ - <appendix id="debugger"> - <title>The PHP Debugger</title> - - <sect1 id="debugger-using"> - <title>Using the Debugger</title> - - <para> +<appendix id="debugger"> + <title>The PHP Debugger</title> + <sect1 id="debugger-using"> + <title>Using the Debugger</title> + <para> PHP's internal debugger is useful for tracking down evasive bugs. The debugger works by connecting to a <acronym>TCP</acronym> port for every time PHP starts up. All error messages from that @@ -12,47 +10,45 @@ intended for "debugging server" that can run inside an <acronym>IDE</acronym> or programmable editor (such as Emacs). </para> - <para> + <para> How to set up the debugger: <orderedlist> - <listitem> - <simpara> - Set up a TCP port for the debugger in the <link - linkend="configuration.file">configuration file</link> (<link - linkend="ini.debugger.port">debugger.port</link>) and enable it + <listitem> + <simpara> + Set up a TCP port for the debugger in the <link linkend="configuration.file">configuration file</link> (<link linkend="ini.debugger.port">debugger.port</link>) and enable it (<link linkend="ini.debugger.enabled">debugger.enabled</link>). </simpara> - </listitem> - <listitem> - <simpara> + </listitem> + <listitem> + <simpara> Set up a TCP listener on that port somewhere (for example <command>socket -l -s 1400</command> on UNIX). </simpara> - </listitem> - <listitem> - <simpara> + </listitem> + <listitem> + <simpara> In your code, run "debugger_on(<replaceable>host</replaceable>)", where <replaceable>host</replaceable> is the IP number or name of the host running the <acronym>TCP</acronym> listener. </simpara> - </listitem> - </orderedlist> + </listitem> + </orderedlist> Now, all warnings, notices etc. will show up on that listener socket, <emphasis>even if you them turned off with - <function>error_reporting</function></emphasis>. + <function>error_reporting</function> + </emphasis>. </para> - <note> - <para> + <note> + <para> The code for the debugger has not been ported to PHP 4, at the present time only PHP 3 supports the debugger code. </para> - </note> - </sect1> - - <sect1 id="debugger-protocol"> - <title>Debugger Protocol</title> - <para> + </note> + </sect1> + <sect1 id="debugger-protocol"> + <title>Debugger Protocol</title> + <para> The debugger protocol is line-based. Each line has a <emphasis>type</emphasis>, and several lines compose a <emphasis>message</emphasis>. Each message starts with a line of @@ -60,178 +56,228 @@ the type <literal>end</literal>. PHP may send lines for different messages simultaneously. </para> - <para> + <para> A line has this format: <informalexample> - <literallayout> -<replaceable>date</replaceable> <replaceable>time</replaceable> -<replaceable>host</replaceable>(<replaceable>pid</replaceable>) + <literallayout> + <replaceable>date</replaceable> + <replaceable>time</replaceable> + <replaceable>host</replaceable>(<replaceable>pid</replaceable>) <replaceable>type</replaceable>: <replaceable>message-data</replaceable> - </literallayout> - </informalexample> - <variablelist> - <varlistentry> - <term><replaceable>date</replaceable></term> - <listitem> - <simpara> + </literallayout> + </informalexample> + <variablelist> + <varlistentry> + <term> + <replaceable>date</replaceable> + </term> + <listitem> + <simpara> Date in ISO 8601 format (<replaceable>yyyy</replaceable>-<replaceable>mm</replaceable>-<replaceable>dd</replaceable>) </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>time</replaceable></term> - <listitem> - <simpara>Time including microseconds: + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>time</replaceable> + </term> + <listitem> + <simpara>Time including microseconds: <replaceable>hh</replaceable>:<replaceable>mm</replaceable>:<replaceable>uuuuuu</replaceable> - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>host</replaceable></term> - <listitem> - <simpara> + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>host</replaceable> + </term> + <listitem> + <simpara> DNS name or IP address of the host where the script error was generated. </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>pid</replaceable></term> - <listitem> - <simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>pid</replaceable> + </term> + <listitem> + <simpara> PID (process id) on <replaceable>host</replaceable> of the process with the PHP script that generated this error. </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>type</replaceable></term> - <listitem> - <para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>type</replaceable> + </term> + <listitem> + <para> Type of line. Tells the receiving program about what it should treat the following data as: <table> - <title>Debugger Line Types</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Name</entry> - <entry>Meaning</entry> - </row> - </thead> - <tbody> - <row> - <entry><literal>start</literal></entry> - <entry> + <title>Debugger Line Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Name</entry> + <entry>Meaning</entry> + </row> + </thead> + <tbody> + <row> + <entry> + <literal>start</literal> + </entry> + <entry> Tells the receiving program that a debugger message starts here. The contents of <replaceable>data</replaceable> will be the type of error message, listed below. </entry> - </row> - <row> - <entry><literal>message</literal></entry> - <entry>The PHP error message.</entry> - </row> - <row> - <entry><literal>location</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>message</literal> + </entry> + <entry>The PHP error message.</entry> + </row> + <row> + <entry> + <literal>location</literal> + </entry> + <entry> File name and line number where the error occured. The first <literal>location</literal> line will always contain the top-level location. <replaceable>data</replaceable> will contain - <literal><replaceable>file</replaceable>:<replaceable>line</replaceable></literal>. + <literal> + <replaceable>file</replaceable>:<replaceable>line</replaceable> + </literal>. There will always be a <literal>location</literal> line after <literal>message</literal> and after every <literal>function</literal>. </entry> - </row> - <row> - <entry> - <literal>frames</literal></entry> <entry>Number of frames + </row> + <row> + <entry> + <literal>frames</literal> + </entry> + <entry>Number of frames in the following stack dump. If there are four frames, expect information about four levels of called functions. If no "frames" line is given, the depth should be assumed to be 0 (the error occured at top-level). </entry> - </row> - <row> - <entry> - <literal>function</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>function</literal> + </entry> + <entry> Name of function where the error occured. Will be repeated once for every level in the function call stack. </entry> - </row> - <row> - <entry><literal>end</literal></entry> - <entry> + </row> + <row> + <entry> + <literal>end</literal> + </entry> + <entry> Tells the receiving program that a debugger message ends here. </entry> - </row> - </tbody> - </tgroup> - </table> - </para> - </listitem> - </varlistentry> - <varlistentry> - <term><replaceable>data</replaceable></term> - <listitem> - <simpara>Line data.</simpara> - </listitem> - </varlistentry> - </variablelist> - - <table> - <title>Debugger Error Types</title> - <tgroup cols="2"> - <thead> - <row> - <entry>Debugger</entry> - <entry>PHP Internal</entry> - </row> - </thead> - <tbody> - <row> - <entry><errortype>warning</errortype></entry> - <entry><errortype>E_WARNING</errortype></entry> - </row> - <row> - <entry><errortype>error</errortype></entry> - <entry><errortype>E_ERROR</errortype></entry> - </row> - <row> - <entry><errortype>parse</errortype></entry> - <entry><errortype>E_PARSE</errortype></entry> - </row> - <row> - <entry><errortype>notice</errortype></entry> - <entry><errortype>E_NOTICE</errortype></entry> - </row> - <row> - <entry><errortype>core-error</errortype></entry> - <entry><errortype>E_CORE_ERROR</errortype></entry> - </row> - <row> - <entry><errortype>core-warning</errortype></entry> - <entry><errortype>E_CORE_WARNING</errortype></entry> - </row> - <row> - <entry><errortype>unknown</errortype></entry> - <entry>(any other)</entry> - </row> - </tbody> - </tgroup> - </table> - - <example> - <title>Example Debugger Message</title> - <literallayout> + </row> + </tbody> + </tgroup> + </table> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <replaceable>data</replaceable> + </term> + <listitem> + <simpara>Line data.</simpara> + </listitem> + </varlistentry> + </variablelist> + <table> + <title>Debugger Error Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Debugger</entry> + <entry>PHP Internal</entry> + </row> + </thead> + <tbody> + <row> + <entry> + <errortype>warning</errortype> + </entry> + <entry> + <errortype>E_WARNING</errortype> + </entry> + </row> + <row> + <entry> + <errortype>error</errortype> + </entry> + <entry> + <errortype>E_ERROR</errortype> + </entry> + </row> + <row> + <entry> + <errortype>parse</errortype> + </entry> + <entry> + <errortype>E_PARSE</errortype> + </entry> + </row> + <row> + <entry> + <errortype>notice</errortype> + </entry> + <entry> + <errortype>E_NOTICE</errortype> + </entry> + </row> + <row> + <entry> + <errortype>core-error</errortype> + </entry> + <entry> + <errortype>E_CORE_ERROR</errortype> + </entry> + </row> + <row> + <entry> + <errortype>core-warning</errortype> + </entry> + <entry> + <errortype>E_CORE_WARNING</errortype> + </entry> + </row> + <row> + <entry> + <errortype>unknown</errortype> + </entry> + <entry>(any other)</entry> + </row> + </tbody> + </tgroup> + </table> + <example> + <title>Example Debugger Message</title> + <literallayout> 1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice 1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable 1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (null):7 @@ -240,12 +286,10 @@ 1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10 1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice </literallayout> - </example> - </para> - </sect1> - - </appendix> - + </example> + </para> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml Index: phpdoc/kr/appendices/escaping.xml diff -u phpdoc/kr/appendices/escaping.xml:1.2 phpdoc/kr/appendices/escaping.xml:1.3 --- phpdoc/kr/appendices/escaping.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/escaping.xml Thu Jan 11 20:10:47 2001 @@ -1,4 +1,4 @@ -<chapt>Escaping data +<chapt>Escaping data <sect>PHP string escape chars <sect>URL encoding (GET) <sect>POST method Index: phpdoc/kr/appendices/history.xml diff -u phpdoc/kr/appendices/history.xml:1.2 phpdoc/kr/appendices/history.xml:1.3 --- phpdoc/kr/appendices/history.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/history.xml Thu Jan 11 20:10:47 2001 @@ -1,3 +1,3 @@ -<chapt>PHP's history +<chapt>PHP's history <sect>Overview of PHP's development Index: phpdoc/kr/appendices/migration.xml diff -u phpdoc/kr/appendices/migration.xml:1.2 phpdoc/kr/appendices/migration.xml:1.3 --- phpdoc/kr/appendices/migration.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/migration.xml Thu Jan 11 20:10:47 2001 @@ -1,91 +1,85 @@ -<appendix id="migration"> - <title>Migrating from PHP/FI 2.0 to PHP 3.0</title> - - <sect1 id="migration-about"> - <title>About the incompatbilities in 3.0</title> - <simpara> - PHP 3.0 is rewritten from the ground up. It has a proper parser - that is much more robust and consistent than 2.0's. 3.0 is also - significantly faster, and uses less memory. However, some of - these improvements have not been possible without compatibility - changes, both in syntax and functionality.</simpara> - - <simpara> - In addition, PHP's developers have tried to clean up both PHP's - syntax and semantics in version 3.0, and this has also caused some - incompatibilities. In the long run, we believe that these changes - are for the better.</simpara> - - <simpara> - This chapter will try to guide you through the incompatibilities - you might run into when going from PHP/FI 2.0 to PHP 3.0 and help - you resolve them. New features are not mentioned here unless - necessary.</simpara> - - <simpara> - A conversion program that can automatically convert your old - PHP/FI 2.0 scripts exists. It can be found in the <filename class="directory">convertor</filename> subdirectory of the PHP 3.0 - distribution. This program only catches the syntax changes though, - so you should read this chapter carefully anyway.</simpara></sect1> - - <sect1 id="migration-startendtags"> - <title>Start/end tags</title> - - <para> - The first thing you probably will notice is that PHP's start and end - tags have changed. The old <literal><? ></literal> form has been - replaced by three new possible forms: +<appendix id="migration"> + <title>PHP/FI 2.0 ìì PHP 3.0ë¡ ì´ì£¼</title> + <sect1 id="migration-about"> + <title>3.0ì ë¹íì±ì ëí´ì</title> + <simpara> + PHP 3.0ì ì²ìë¶í° ë¤ì ìì¬ì¡ë¤. + ê·¸ê²ì 2.0ì ë¹í´ í¨ì¬ë í¼í¼íê³ ì¼ê´ë íì(ëª ë ¹í´ì)ì ì í©íë¤. + 3.0ì ì´ë¯¸ ìë¹í 빨ë¼ì§ê³ , ëì± ì ì ë©ëª¨ë¦¬ë¥¼ ì¬ì©íë¤. íì§ë§, + ì´ë¤ì í¥ìì ë ì´ì 구문과 í¨ìì í¸íì±ì ê°ë¥íê² íì§ ëª»íë¤. + </simpara> + <simpara> + 첨ë¶íìë©´, PHPê°ë°ìë¤ì 3.0ìì PHPì 구문과 ìë¯¸ì²´ê³ ì쪽 ë¤ ì 리를 ìëíê³ + ì´ê²ì ì½ê°ì ë¹í¸íì±ì ì¼ê¸°ìì¼°ë¤. ë©ë¦¬ë³´ìë©´ ì°ë¦° ê·¸ê²ì´ ë ëì ê²ì ìí ë³íë¤ì´ìë¤ê³ + 믿ëë¤. + </simpara> + <simpara> + ì´ë² ì¥ì ë¹ì ìê² ìë§ PHP/FI 2.0ì PHP 3.0ì¼ë¡ ê°ëì ë¹í¸íì±ì ìë´í ê²ì´ê³ , + ê·¸ê²ì í´ê²°íë ¤ë ë¹ì ì ëëë¤. + ìë¡ì´ 기ë¥ì íìê° ìë¤ë©´ ì¬ê¸°ì ì¸ê¸íì§ ìëë¤. + </simpara> + <simpara> + ë³í íë¡ê·¸ë¨ì ìëì¼ë¡ ë¹ì ì 구 PHP/FI 2.0 ì¤í¬ë¦½í¸ë¥¼ ë³íìì¼ì¤ë¤. + ì´ê²ì + PHP 3.0 ë°°í¬ë³¸ì ìë¸ëë í 리 <filename class="directory">convertor</filename>ìì ì°¾ì ì ìë¤. + ì´ íë¡ê·¸ë¨ì ë¨ì§ 구문ì ì°¾ì ë°ê¾¸ë ê²ì´ê¸°ì ë¹ì ì ì´ì¨ë ì´ë² ì¥ì ì¡°ì¬ì¤ë ì½ì´ ëê°ì¼ í ê²ì´ë¤. + </simpara> + </sect1> + <sect1 id="migration-startendtags"> + <title>ìì/ë íê·¸ Start/end tags</title> + <para> + ë¹ì ìê² ìë§ ì£¼ìíë 첫ë²ì§¸ ê²ì PHPì ììê³¼ ëì´ ë°ëìë¤ë ê²ì´ë¤. + ìì ì <literal><? ></literal>ììì´ ì¸ê°ì§ ììì¼ë¡ ë°ëìë¤: <example> - <title>Migration: old start/end tags</title> - <programlisting> + <title>ì´ì£¼: ìì ìì/ë íê·¸</title> + <programlisting> <? echo "This is PHP/FI 2.0 code.\n"; > -</programlisting></example> - - As of version 2.0, PHP/FI also supports this variation: +</programlisting> + </example> +2.0ë²ì ìë, PHP/FI ë ì´ìê°ì ë³í를 ì§ìíê³ ììë¤. +As of version 2.0, PHP/FI also supports this variation: - <example><title>Migration: first new start/end tags</title> - <programlisting> + <example> + <title>ì´ì£¼: ìë¡ì´ 첫ë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <? echo "This is PHP 3.0 code!\n"; ?> -</programlisting></example> - - Notice that the end tag now consists of a question mark and a - greater-than character instead of just greater-than. However, if - you plan on using XML on your server, you will get problems with - the first new variant, because PHP may try to execute the XML - markup in XML documents as PHP code. Because of this, the - following variation was introduced: - - <example><title>Migration: second new start/end tags</title> - <programlisting> +</programlisting> + </example> +ì´ê²ì ë쪽 íê·¸ê° íëì ë¹êµë¬¸ìëì ì 물ìí ë§í¬ì ë¹êµë¬¸ìë¡ ì´ë£¨ì¡ë¤ë ê²ì ìì ìë¤. +ìë§ ë¹ì ì´ ë¹ì ì ìë²ì XML를 ì°ê¸°ë¥¼ ê³ííë¤ë©´ ì´ ìë¡ì´ ë³íë ëªëª 문ì ì ë¤ì ê°ì§ê³ ìë¤. +ìëíë©´ PHPë ìë§ XML문ììì XMLë§í¬ì ì PHPì½ëì²ë¼ ì¤íí ê²ì´ë¤. +ì´ê² ë문ì ë¤ìê³¼ ê°ì´ ìê°íë ê²ì ë°ë¥¸ë¤: + <example> + <title>ì´ì£¼: ìë¡ì´ ëë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <?php echo "This is PHP 3.0 code!\n"; ?> -</programlisting></example> - - Some people have had problems with editors that don't understand - the processing instruction tags at all. Microsoft FrontPage is one - such editor, and as a workaround for these, the following variation - was introduced as well: +</programlisting> + </example> - <example><title>Migration: third new start/end tags</title> - <programlisting> +ëªëª ì¬ëì ìëí°ë¤ì´ ì²ë¦¬êµ¬ë¬¸íê·¸ë¤ì ì¸ìíì§ ëª»íë 문ì 를 ê°ì§ê³ ììë¤. +ë§ì´í¬ë¡ìíí¸ íë¡ í¸íì´ì§ë ê·¸ë¬í ìëí°ë¤ì¤ íë ìê³ , +ë¤ìê³¼ ê°ì´ ìê°íë ë³í를 ë°ë¥¸ë¤: + <example> + <title>ì´ì£¼: ìë¡ì´ ì¸ë²ì§¸ ìì/ë íê·¸</title> + <programlisting> <script language="php"> echo "This is PHP 3.0 code!\n"; </script> -</programlisting></example></para></sect1> - - - <sect1 id="migration-if-endif"> - <title>if..endif syntax</title> - - <para> - The `alternative' way to write if/elseif/else statements, using if(); - elseif(); else; endif; cannot be efficiently implemented without - adding a large amount of complexity to the 3.0 parser. Because of - this, the syntax has been changed: +</programlisting> + </example> + </para> + </sect1> + <sect1 id="migration-if-endif"> + <title>if..endif 구문</title> + <para> + 'ì íì ì¸'ë°©ë² if/elseif/elseííì ì¸ì ìê³ , if(); elseif(); else; endif();ì ì¬ì©ì + ë§ì ìì ë³µì¡í¨ì 3.0 íìì ì¶ê°ìì´ í¨ê³¼ì ì¸ ë구를 ì¬ì©í ì ìë¤ + ê·¸ë¬í기 ë문ì êµ¬ë¬¸ì´ ë°ëìë¤: <example> - <title>Migration: old if..endif syntax</title> - <programlisting> + <title>ì´ì£¼: ìì ì if..endif 구문</title> + <programlisting> if ($foo); echo "yep\n"; elseif ($bar); @@ -93,10 +87,11 @@ else; echo "nope\n"; endif; -</programlisting></example> - <example> - <title>Migration: new if..endif syntax</title> - <programlisting> +</programlisting> + </example> + <example> + <title>ì´ì£¼: ìë¡ì´ if..endif 구문</title> + <programlisting> if ($foo): echo "yep\n"; elseif ($bar): @@ -104,48 +99,49 @@ else: echo "nope\n"; endif; -</programlisting></example> - - Notice that the semicolons have been replaced by colons in all - statements but the one terminating the expression (endif).</para></sect1> - - <sect1 id="migration-while"> - <title>while syntax</title> - <para> - Just like with if..endif, the syntax of while..endwhile has changed - as well: - <example><title>Migration: old while..endwhile syntax</title> - <programlisting> +</programlisting> + </example> + ì¸ë¯¸ì½ë¡ ì 모ë ííìì ì½ë¡ ì¼ë¡ ë°ëìì¼ë ííììì íë²ì ì¢ ê²°ë¨ì 주목íë¼. (endif). +</para> + </sect1> + <sect1 id="migration-while"> + <title>while 구문</title> + <para> + if..endifì ê°ì´ while..endwhileì ë°ëìë¤: + <example> + <title>ì´ì£¼: ìì ì while..endwhile 구문</title> + <programlisting> while ($more_to_come); ... endwhile; -</programlisting></example> - <example><title>Migration: new while..endwhile syntax</title> - <programlisting> +</programlisting> + </example> + <example> + <title>ì´ì£¼: ìë¡ì´ while..endwhile 구문</title> + <programlisting> while ($more_to_come): ... endwhile; -</programlisting></example> - </para> - <warning> - <simpara> - If you use the old while..endwhile syntax in PHP 3.0, you will get - a never-ending loop. +</programlisting> + </example> + </para> + <warning> + <simpara> + ë¹ì ì´ ìì ì while..endwhile구문ì PHP 3.0ìì ì¬ì©íë¤ë©´ 무í루í를 íê² ë ê²ì´ë¤. </simpara> - </warning></sect1> - - <sect1 id="migration-expr"> - <title>Expression types</title> - <simpara> - PHP/FI 2.0 used the left side of expressions to determine what type - the result should be. PHP 3.0 takes both sides into account when - determining result types, and this may cause 2.0 scripts to behave - unexpectedly in 3.0.</simpara> - <simpara></simpara> - - <para> - Consider this example: - <informalexample><programlisting> + </warning> + </sect1> + <sect1 id="migration-expr"> + <title>ííì íì </title> + <simpara> + PHP/FI 2.0ì ì¼ìª½ì ê²°ê³¼ íì ì íì íë ííìì ì¬ì©íë¤ +used the left side of expressions to determine what type +PHP 3.0ì ê²°ê³¼ íì ì ê²°ì í ë ê³ì ì¼ë¡ë¶í° ì쪽ì ë°ëë¤. ê·¸ë¦¬ê³ ìë§ 2.0 ì¤í¬ë¦½í¸ì¸í´ 3.0ììë ë»ë°ì ë°ìì ê°ì§ê² ë ê²ì´ë¤.</simpara> + <simpara/> + <para> +ì´ ìì 를 ê²í íë¼: + <informalexample> + <programlisting> $a[0]=5; $a[1]=7; @@ -154,154 +150,141 @@ echo "$keyn"; next($a); } -</programlisting></informalexample> - - In PHP/FI 2.0, this would display both of $a's indices. In PHP - 3.0, it wouldn't display anything. The reason is that in PHP 2.0, - because the left argument's type was string, a string comparison - was made, and indeed <literal>""</literal> does not equal - <literal>"0"</literal>, and the loop went through. In PHP 3.0, - when a string is compared with an integer, an integer comparison is - made (the string is converted to an integer). This results in - comparing <literal>atoi("")</literal> which is - <literal>0</literal>, and <literal>variablelist</literal> which is - also <literal>0</literal>, and since <literal>0==0</literal>, the - loop doesn't go through even once. - - </para> - <para> - The fix for this is simple. Replace the while statement with: - <informalexample><programlisting> +</programlisting> + </informalexample> +PHP/FI 2.0ììë $aì ì¸ë±ì¤ ìì ì쪽 모ë ë³´ì¬ì¤ë¤. +PHP 3.0ììë ì무ê²ë ë³´ì¬ì£¼ì§ ìëë¤. +ê·¸ ì´ì ë PHP2.0ì ìë¤ +ì¼ìª½ ì¸ìì íì ì´ ë¬¸ìì´ë¹êµë¥¼ ìí´ ë§ë¤ì´ì§ 문ìì´ì´ê³ , ì¤ì <literal>""</literal>ê³¼ "0"ë 루í를 íµíë ëì ê°ì§ ìë¤, +PHP 3.0ììë 문ìì´ì´ ì ìë¹êµë¥¼ ìí´ ë§ë¤ì´ì§ ì ìì ë¹êµë ë (문ìì´ì ì ìë¡ ë³íëë¤), +<literal>atoi("")</literal> ë¹êµì ê²°ê³¼ë 0 ê³¼ <literal>variablelist</literal>, 0 ê³¼ <literal>0==0</literal> ì´í, +루íë íë²ë íµíì§ ëª»íë¤. +</para> + <para> +ê°ë¨íê² while구문ì ë°ê¿ì¼ë¡ì¨ ê³ ì³¤ë¤: + <informalexample> + <programlisting> while ((string)$key != "") { -</programlisting></informalexample></para></sect1> - - - <sect1 id="migration-errors"> - <title>Error messages have changed</title> - <simpara> - PHP 3.0's error messages are usually more accurate than 2.0's were, - but you no longer get to see the code fragment causing the error. - You will be supplied with a file name and a line number for the - error, though. - </simpara></sect1> - - - <sect1 id="migration-booleval"> - <title>Short-circuited boolean evaluation</title> - <simpara> - In PHP 3.0 boolean evaluation is short-circuited. This means that - in an expression like <literal>(1 || test_me())</literal>, the - function <function>test_me</function> would not be executed since - nothing can change the result of the expression after the - <literal>1</literal>.</simpara> - - <simpara> - This is a minor compatibility issue, but may cause unexpected - side-effects.</simpara></sect1> - - - <sect1 id="migration-truefalse"> - <title>Function true/false return values</title> - <simpara> - Most internal functions have been rewritten so they return TRUE - when successful and FALSE when failing, as opposed to 0 and -1 in - PHP/FI 2.0, respectively. The new behaviour allows for more - logical code, like <literal>$fp = fopen("/your/file") or - fail("darn!");</literal>. Because PHP/FI 2.0 had no clear rules - for what functions should return when they failed, most such - scripts will probably have to be checked manually after using the - 2.0 to 3.0 convertor.</simpara> - <para> - <example> - <title>Migration from 2.0: return values, old code</title> - <programlisting> +</programlisting> + </informalexample> + </para> + </sect1> + <sect1 id="migration-errors"> + <title>ì¤ë¥ ë©ì¸ì§ë¥¼ ë°ê¿¨ë¤.</title> + <simpara> + PHP3.0ì ì¤ë¥ ë©ì¸ì§ë 2.0ë³´ë¤ ë ì ì©íê² ì íí´ì¡ë¤. ê·¸ë¬ë, + ë¹ì ì ìë¬ë¡ ì¸í ì½ëì 깨ì§ì ë ì´ì ë°ì ë³¼ ì ìë¤. + ë¤ë§ ë¹ì ì ì¤ë¥ë¥¼ ìí íì¼ëª ê³¼ ì¤ë²í¸ë¥¼ ì ê³µë°ì ê²ì´ë¤. + </simpara> + </sect1> + <sect1 id="migration-booleval"> + <title>ë¨ë½ë ë¶ë¦° íê° + Short-circuited boolean evaluation</title> + <simpara> + PHP 3.0ì ë¶ë¦° íê°ë ë¨ë½ëìë¤. ì´ ë»ì <literal>(1 || test_me())</literal>ê°ì ííììì <function>test_me</function>í¨ìë <literal>1</literal>ì´í ííì ê²°ê³¼ì ë°ê¾¸ì§ ìë í ì¤íëì§ ìëë¤. +</simpara> + <simpara> + ì´ê±´ ì¤ìíì§ ìë í¸íì± ì´ìì´ë, ë¤ë¥¸ 쪽ì ìê¸°ì¹ ëª»íê² ìí¥ì ì¤ ì ìë¤. + </simpara> + </sect1> + <sect1 id="migration-truefalse"> + <title>í¨ì 리í´ê° true/false/title</title> + <simpara> + PHP/FI 2.0ì ê°ê° ë°ëëë 0ê³¼ -1ì²ë¼ ëë¶ë¶ì ë´ì¥ í¨ìë¤ì + trueì ì±ê³µì ì¼ë falseë ì¤í¨íìë 리í´ê°ì 주ëë¡ ë¤ì ìì¬ì¡ë¤. + ìë¡ì´ íëìë <literal>$fp = fopen("/your/file") or fail("darn!");</literal>ê°ì ë ë§ì ë ¼ë¦¬ì ì½ë를 íë½íë¤. + í¨ìê° ë¦¬í´ê°ì ì ëë¡ ëê¸°ì§ ëª»í ë PHP/FI 2.0ì ëì´ì 깨ëí ê·ì¹ì´ ìëë¤. + ëë¶ë¶ì ê·¸ë¬í ì¤í¬ë¦½í¸ë 2.0ìì 3.0ì ë³íì´í ìë§ ììì ì¼ë¡ ì ê²í´ì¼ íë¤. + </simpara> + <para> + <example> + <title>2.0ìì ì´ì£¼: 리í´ê°, ìì ì ì½ë</title> + <programlisting> $fp = fopen($file, "r"); if ($fp == -1); echo("Could not open $file for reading<br>\n"); endif; </programlisting> - </example> - <example> - <title>Migration from 2.0: return values, new code</title> - <programlisting> + </example> + <example> + <title>2.0ìì ì´ì£¼: 리í´ê°, ìë¡ì´ ì½ë</title> + <programlisting> $fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n"); </programlisting> - </example></para></sect1> - - - <sect1 id="migration-other"> - <title>Other incompatibilities</title> - - <itemizedlist> - <listitem><simpara> - The PHP 3.0 Apache module no longer supports Apache versions - prior to 1.2. Apache 1.2 or later is required.</simpara></listitem> - - <listitem><simpara> <function>echo</function> no longer - supports a format string. Use the - <function>printf</function> function instead.</simpara></listitem> - - <listitem><simpara> - In PHP/FI 2.0, an implementation side-effect caused - <literal>$foo[0]</literal> to have the same effect as - <literal>$foo</literal>. This is not true for PHP 3.0.</simpara></listitem> - - <listitem><simpara> - Reading arrays with <literal>$array[]</literal> is no longer - supported</simpara> - - <simpara> - That is, you cannot traverse an array by having a loop that does - <literal>$data = $array[]</literal>. Use - <function>current</function> and <function>next</function> - instead.</simpara> - <simpara> - Also, <literal>$array1[] = $array2</literal> does not append the - values of <literal>$array2</literal> to <literal>$array1</literal>, - but appends <literal>$array2</literal> as the last entry of - <literal>$array1</literal>. See also multidimensional array - support.</simpara></listitem> - - <listitem> - <simpara> <literal>"+"</literal> is no longer overloaded as a - concatenation operator for strings, instead it converts it's - arguments to numbers and performs numeric addition. Use - <literal>"."</literal> instead.</simpara></listitem> - </itemizedlist> - - <example> - <title>Migration from 2.0: concatenation for strings</title> - <programlisting> + </example> + </para> + </sect1> + <sect1 id="migration-other"> + <title>ê·¸ë°ì ë¹í¸íì±ë¤</title> + <itemizedlist> + <listitem> + <simpara> + PHP 3.0 ìíì¹ ëª¨ëì ëì´ì ìíì¹ 1.2ì´ì ë²ì ì ì§ìíì§ ìëë¤. + 1.2ë ê·¸ ì´í를 ì구íë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <function>echo</function>ë ëì´ì ììíë 문ìì´ì ì§ìíì§ ìëë¤. + ëì ì <function>printf</function>ì ì¬ì©íë¼.</simpara> + </listitem> + <listitem> + <simpara> + PHP/FI 2.0ììë <literal>$foo[0]</literal>ê³¼ <literal>$foo</literal>ë + ê°ì í¨ê³¼ë¥¼ ë¤ë¥¸ 쪽ìì ìííìë¤. PHP 3.0ìì ì´ê²ì ìíëì§ ìëë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <literal>$array[]</literal>ê°ì ë°°ì´ ì½ê¸°ë ëì´ì ì§ìíì§ ìëë¤. + </simpara> + <simpara> + ê·¸ê²ì ëì´ì ë¹ì ì´ ë£¨í를 ì´ì©í <literal>$data = $array[]</literal>ê°ì + ë°°ì´ ë기기를 í ì ìë¤. + ëì <function>current</function>ê³¼ <function>next</function>ì ì¬ì©íë¼. + </simpara> + <simpara> + ë§ì°¬ê°ì§ë¡ <literal>$array1[] = $array2</literal>ì <literal>$array2</literal>ì + <literal>$array1</literal>ì ê°ê³¼ ê°ì§ ìì§ë§, <literal>$array2</literal>ë + <literal>$array1</literal>ì ë§ì§ë§ ììì ê°ë¤. ì´ê²ì ë¤ì°¨ì ë°°ì´ë ë§ì°¬ê°ì§ë¡ + ì§ìíë¤. + </simpara> + </listitem> + <listitem> + <simpara> + <literal>"+"</literal>ì ëì´ì 문ìì´ì ì°ê²°ìê° ìëë¤, ëì ê·¸ê²ì ì«ì ì¸ìì + ì«ìì ë§ì ì¼ë¡ ë°ëìë¤. ëì <literal>"."</literal>를 ì¬ì©íë¼. + </simpara> + </listitem> + </itemizedlist> + <example> + <title>2.0ìì ì´ì£¼: 문ìì´ ì°ê²°</title> + <programlisting> echo "1" + "1"; </programlisting> - - <para> - In PHP 2.0 this would echo 11, in PHP 3.0 it would echo 2. Instead - use: - - <programlisting> + <para> + PHP 2.0ììë 11ë¡ ì¶ë ¥ëì§ë§, 3.0ììë 2ë¡ ì¶ë ¥ëë¤. ëì²´íìë©´: +<programlisting> echo "1"."1"; </programlisting> - - <programlisting> +<programlisting> $a = 1; $b = 1; echo $a + $b; -</programlisting></para> - - <para> - This would echo 2 in both PHP 2.0 and 3.0. +</programlisting> + </para> + <para> + 2.0ê³¼ 3.0 모ëë¤ 2ê° ì¶ë ¥ëë¤. <programlisting> $a = 1; $b = 1; echo $a.$b; </programlisting> - This will echo 11 in PHP 3.0.</para> - </example></sect1> - - </appendix> - + 3.0ììë 11ì´ ì¶ë ¥ëë¤.</para> + </example> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml Index: phpdoc/kr/appendices/phpdevel.xml diff -u phpdoc/kr/appendices/phpdevel.xml:1.2 phpdoc/kr/appendices/phpdevel.xml:1.3 --- phpdoc/kr/appendices/phpdevel.xml:1.2 Tue Jan 9 16:33:39 2001 +++ phpdoc/kr/appendices/phpdevel.xml Thu Jan 11 20:10:47 2001 @@ -1,71 +1,66 @@ -<appendix id="phpdevel"> - <title>PHP development</title> - - <simpara></simpara> - - <sect1 id="phpdevel-addfunc"> - <title>Adding functions to PHP 3</title> - <sect2 id="phpdevel-addfunc-prototype"> - <title>Function Prototype</title> - <para> - All functions look like this: +<appendix id="phpdevel"> + <title>PHP ê°ë°</title> + <simpara/> + <sect1 id="phpdevel-addfunc"> + <title>PHP 3ì í¨ì ì¶ê°</title> + <sect2 id="phpdevel-addfunc-prototype"> + <title>í¨ì í본</title> + <para> +모ë í¨ìë ë¤ìê³¼ ê°ë¤: <programlisting> void php3_foo(INTERNAL_FUNCTION_PARAMETERS) { } </programlisting> - Even if your function doesn't take any arguments, this is how it is - called.</para></sect2> +ë¹ë¡ í¨ìê° ì´ë¤ ì¸ìë ê°ì§ ìëë¼ë í¨ìë¼ ì¹íë¤. +</para> + </sect2> + <sect2 id="phpdevel-addfunc-args"> + <title>í¨ì ì¸ì</title> + <para> - <sect2 id="phpdevel-addfunc-args"> - <title>Function Arguments</title> - <para> Arguments are always of type pval. This type contains a union which has the actual type of the argument. So, if your function takes two arguments, you would do something like the following at the top of your function:</para> - - <para> - <example> - <title>Fetching function arguments</title> - <programlisting> + <para> + <example> + <title>Fetching function arguments</title> + <programlisting> pval *arg1, *arg2; if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&arg1,&arg2)==FAILURE) { WRONG_PARAM_COUNT; } </programlisting> - </example> + </example> NOTE: Arguments can be passed either by value or by reference. In both cases you will need to pass &(pval *) to getParameters. If you want to check if the n'th parameter was sent to you by reference or not, you can use the function, ParameterPassedByReference(ht,n). It will return either 1 or 0.</para> - - <simpara> + <simpara> When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over with the parameter by calling pval_destructor on it, or if it's an ARRAY you want to add to, you can use functions similar to the ones in internal_functions.h which manipulate return_value as an ARRAY.</simpara> - - <simpara> + <simpara> Also if you change a parameter to IS_STRING make sure you first assign the new estrdup()'ed string and the string length, and only later change the type to IS_STRING. If you change the string of a parameter which already IS_STRING or IS_ARRAY you should run - pval_destructor on it first.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-varargs"> - <title>Variable Function Arguments</title> - <para> + pval_destructor on it first.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-varargs"> + <title>Variable Function Arguments</title> + <para> A function can take a variable number of arguments. If your function can take either 2 or 3 arguments, use the following:</para> - - <para> - <example> - <title>Variable function arguments</title> - <programlisting> + <para> + <example> + <title>Variable function arguments</title> + <programlisting> pval *arg1, *arg2, *arg3; int arg_count = ARG_COUNT(ht); @@ -74,59 +69,60 @@ WRONG_PARAM_COUNT; } </programlisting> - </example></para></sect2> - - <sect2 id="phpdevel-addfunc-using-args"> - <title>Using the Function Arguments</title> - <para> + </example> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-using-args"> + <title>Using the Function Arguments</title> + <para> The type of each argument is stored in the pval type field. This type can be any of the following: <table> - <title>PHP Internal Types</title> - <tgroup cols="2"> - <tbody> - <row> - <entry>IS_STRING</entry> - <entry>String</entry> - </row> - <row> - <entry>IS_DOUBLE</entry> - <entry>Double-precision floating point</entry> - </row> - <row> - <entry>IS_LONG</entry> - <entry>Long integer</entry> - </row> - <row> - <entry>IS_ARRAY</entry> - <entry>Array</entry> - </row> - <row> - <entry>IS_EMPTY</entry> - <entry>None</entry> - </row> - <row> - <entry>IS_USER_FUNCTION</entry> - <entry>??</entry> - </row> - <row> - <entry>IS_INTERNAL_FUNCTION</entry> - <entry>?? (if some of these cannot be passed to a function - delete)</entry> - </row> - <row> - <entry>IS_CLASS</entry> - <entry>??</entry> - </row> - <row> - <entry>IS_OBJECT</entry> - <entry>??</entry> - </row> - </tbody> - </tgroup> - </table></para> - - <para> + <title>PHP Internal Types</title> + <tgroup cols="2"> + <tbody> + <row> + <entry>IS_STRING</entry> + <entry>String</entry> + </row> + <row> + <entry>IS_DOUBLE</entry> + <entry>Double-precision floating point</entry> + </row> + <row> + <entry>IS_LONG</entry> + <entry>Long integer</entry> + </row> + <row> + <entry>IS_ARRAY</entry> + <entry>Array</entry> + </row> + <row> + <entry>IS_EMPTY</entry> + <entry>None</entry> + </row> + <row> + <entry>IS_USER_FUNCTION</entry> + <entry>??</entry> + </row> + <row> + <entry>IS_INTERNAL_FUNCTION</entry> + <entry>?? (if some of these cannot be passed to a function - delete)</entry> + </row> + <row> + <entry>IS_CLASS</entry> + <entry>??</entry> + </row> + <row> + <entry>IS_OBJECT</entry> + <entry>??</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> If you get an argument of one type and would like to use it as another, or if you just want to force the argument to be of a certain type, you can use one of the following conversion @@ -138,28 +134,33 @@ convert_to_string(arg1); convert_to_boolean_long(arg1); /* If the string is "" or "0" it becomes 0, 1 otherwise */ convert_string_to_number(arg1); /* Converts string to either LONG or DOUBLE depending on string */ - </programlisting></para> - - <simpara> + </programlisting> + </para> + <simpara> These function all do in-place conversion. They do not return anything.</simpara> - - <para> + <para> The actual argument is stored in a union; the members are: <itemizedlist> - <listitem><simpara>IS_STRING: arg1->value.str.val</simpara></listitem> - <listitem><simpara>IS_LONG: arg1->value.lval</simpara></listitem> - <listitem><simpara>IS_DOUBLE: arg1->value.dval</simpara></listitem> - </itemizedlist></para></sect2> - - <sect2 id="phpdevel-addfunc-memmgmt"> - <title>Memory Management in Functions</title> - <simpara> + <listitem> + <simpara>IS_STRING: arg1->value.str.val</simpara> + </listitem> + <listitem> + <simpara>IS_LONG: arg1->value.lval</simpara> + </listitem> + <listitem> + <simpara>IS_DOUBLE: arg1->value.dval</simpara> + </listitem> + </itemizedlist> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-memmgmt"> + <title>Memory Management in Functions</title> + <simpara> Any memory needed by a function should be allocated with either emalloc() or estrdup(). These are memory handling abstraction functions that look and smell like the normal malloc() and strdup() functions. Memory should be freed with efree().</simpara> - - <simpara> + <simpara> There are two kinds of memory in this program: memory which is returned to the parser in a variable, and memory which you need for temporary storage in your internal function. When you assign a @@ -168,8 +169,7 @@ estrdup(). This memory should NEVER be freed by you, unless you later in the same function overwrite your original assignment (this kind of programming practice is not good though).</simpara> - - <simpara> + <simpara> For any temporary/permanent memory you need in your functions/library you should use the three emalloc(), estrdup(), and efree() functions. They behave EXACTLY like their counterpart @@ -179,99 +179,96 @@ leak. The meaning of "the functions behave exactly like their counterparts" is: if you efree() something which was not emalloc()'ed nor estrdup()'ed you might get a segmentation - fault. So please take care and free all of your wasted memory.</simpara> - - <simpara> + fault. So please take care and free all of your wasted memory.</simpara> + <simpara> If you compile with "-DDEBUG", PHP 3 will print out a list of all memory that was allocated using emalloc() and estrdup() but never - freed with efree() when it is done running the specified script.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-symtab"> - <title>Setting Variables in the Symbol Table</title> - <para> + freed with efree() when it is done running the specified script.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-symtab"> + <title>Setting Variables in the Symbol Table</title> + <para> A number of macros are available which make it easier to set a variable in the symbol table: <itemizedlist> - <listitem><simpara>SET_VAR_STRING(name,value) <footnoteref linkend="symtab-1"/></simpara></listitem> - <listitem><simpara>SET_VAR_DOUBLE(name,value)</simpara></listitem> - <listitem><simpara>SET_VAR_LONG(name,value)</simpara></listitem> - </itemizedlist></para> - - <para> - <footnote id="symtab-1"> - <simpara> + <listitem> + <simpara>SET_VAR_STRING(name,value) <footnoteref linkend="symtab-1"/> + </simpara> + </listitem> + <listitem> + <simpara>SET_VAR_DOUBLE(name,value)</simpara> + </listitem> + <listitem> + <simpara>SET_VAR_LONG(name,value)</simpara> + </listitem> + </itemizedlist> + </para> + <para> + <footnote id="symtab-1"> + <simpara> Be careful here. The value part must be malloc'ed manually because the memory management code will try to free this pointer later. Do not pass statically allocated memory into a SET_VAR_STRING.</simpara> - </footnote></para> - - <simpara> + </footnote> + </para> + <simpara> Symbol tables in PHP 3.0 are implemented as hash tables. At any given time, &symbol_table is a pointer to the 'main' symbol table, and active_symbol_table points to the currently active symbol table (these may be identical like in startup, or different, if you're inside a function).</simpara> - - <para> + <para> The following examples use 'active_symbol_table'. You should replace it with &symbol_table if you specifically want to work with the 'main' symbol table. Also, the same functions may be applied to arrays, as explained below.</para> - - <para> - <example> - <title>Checking whether $foo exists in a symbol table</title> - <programlisting> + <para> + <example> + <title>Checking whether $foo exists in a symbol table</title> + <programlisting> if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... } else { doesn't exist } </programlisting> - </example> - - <example> - <title>Finding a variable's size in a symbol table</title> - <programlisting> + </example> + <example> + <title>Finding a variable's size in a symbol table</title> + <programlisting> hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue); check(pvalue.type); </programlisting> - </example> + </example> Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can also be used to check variables inside arrays.</para> - - <simpara> + <simpara> If you want to define a new array in a symbol table, you should do the following.</simpara> - - <simpara> + <simpara> First, you may want to check whether it exists and abort appropiately, using hash_exists() or hash_find().</simpara> - - <simpara> + <simpara> Next, initialize the array:</simpara> - - <para> - <example> - <title>Initializing a new array</title> - <programlisting> + <para> + <example> + <title>Initializing a new array</title> + <programlisting> pval arr; if (array_init(&arr) == FAILURE) { failed... }; hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL); </programlisting> - </example> + </example> This code declares a new array, named $foo, in the active symbol table. This array is empty.</para> - - <simpara> + <simpara> Here's how to add new entries to it:</simpara> - - <para> - <example> - <title>Adding entries to a new array</title> - <programlisting> + <para> + <example> + <title>Adding entries to a new array</title> + <programlisting> pval entry; entry.type = IS_LONG; @@ -288,7 +285,7 @@ */ hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); </programlisting> - </example> + </example> If you'd like to modify a value that you inserted to a hash, you must first retrieve it from the hash. To prevent that overhead, @@ -296,29 +293,23 @@ updated with the pval * address of the inserted element inside the hash. If that value is NULL (like in all of the above examples) - that parameter is ignored.</para> - - <simpara> + <simpara> hash_next_index_insert() uses more or less the same logic as "$foo[] = bar;" in PHP 2.0.</simpara> - - <simpara> + <simpara> If you are building an array to return from a function, you can initialize the array just like above by doing:</simpara> - - <programlisting> + <programlisting> if (array_init(return_value) == FAILURE) { failed...; } </programlisting> - - <simpara> + <simpara> ...and then adding values with the helper functions:</simpara> - - <programlisting> + <programlisting> add_next_index_long(return_value,long_value); add_next_index_double(return_value,double_value); add_next_index_string(return_value,estrdup(string_value)); </programlisting> - - <para> + <para> Of course, if the adding isn't done right after the array initialization, you'd probably have to look for the array first: @@ -327,69 +318,96 @@ if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... } else { use arr->value.ht... } - </programlisting></para> - - <simpara> + </programlisting> + </para> + <simpara> Note that hash_find receives a pointer to a pval pointer, and not a pval pointer.</simpara> - - <simpara> + <simpara> Just about any hash function returns SUCCESS or FAILURE (except - for hash_exists(), which returns a boolean truth value).</simpara></sect2> - - <sect2 id="phpdevel-addfunc-retsimple"> - <title>Returning simple values</title> - <simpara> + for hash_exists(), which returns a boolean truth value).</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-retsimple"> + <title>Returning simple values</title> + <simpara> A number of macros are available to make returning values from a - function easier.</simpara> - - <para> + function easier.</simpara> + <para> The RETURN_* macros all set the return value and return from the function: <itemizedlist> - <listitem><simpara>RETURN</simpara></listitem> - <listitem><simpara>RETURN_FALSE</simpara></listitem> - <listitem><simpara>RETURN_TRUE</simpara></listitem> - <listitem><simpara>RETURN_LONG(l)</simpara></listitem> - <listitem><simpara>RETURN_STRING(s,dup) If dup is true, duplicates the string</simpara></listitem> - <listitem><simpara>RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara></listitem> - <listitem><simpara>RETURN_DOUBLE(d)</simpara></listitem> - </itemizedlist></para> - - <para> + <listitem> + <simpara>RETURN</simpara> + </listitem> + <listitem> + <simpara>RETURN_FALSE</simpara> + </listitem> + <listitem> + <simpara>RETURN_TRUE</simpara> + </listitem> + <listitem> + <simpara>RETURN_LONG(l)</simpara> + </listitem> + <listitem> + <simpara>RETURN_STRING(s,dup) If dup is true, duplicates the string</simpara> + </listitem> + <listitem> + <simpara>RETURN_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara> + </listitem> + <listitem> + <simpara>RETURN_DOUBLE(d)</simpara> + </listitem> + </itemizedlist> + </para> + <para> The RETVAL_* macros set the return value, but do not return. <itemizedlist> - <listitem><simpara>RETVAL_FALSE</simpara></listitem> - <listitem><simpara>RETVAL_TRUE</simpara></listitem> - <listitem><simpara>RETVAL_LONG(l)</simpara></listitem> - <listitem><simpara>RETVAL_STRING(s,dup) If dup is true, duplicates the string</simpara></listitem> - <listitem><simpara>RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara></listitem> - <listitem><simpara>RETVAL_DOUBLE(d)</simpara></listitem> - </itemizedlist></para> - - <simpara> + <listitem> + <simpara>RETVAL_FALSE</simpara> + </listitem> + <listitem> + <simpara>RETVAL_TRUE</simpara> + </listitem> + <listitem> + <simpara>RETVAL_LONG(l)</simpara> + </listitem> + <listitem> + <simpara>RETVAL_STRING(s,dup) If dup is true, duplicates the string</simpara> + </listitem> + <listitem> + <simpara>RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (l).</simpara> + </listitem> + <listitem> + <simpara>RETVAL_DOUBLE(d)</simpara> + </listitem> + </itemizedlist> + </para> + <simpara> The string macros above will all estrdup() the passed 's' argument, so you can safely free the argument after calling the macro, or alternatively use statically allocated memory.</simpara> - - <simpara> + <simpara> If your function returns boolean success/error responses, always - use RETURN_TRUE and RETURN_FALSE respectively.</simpara></sect2> - - <sect2 id="phpdevel-addfunc-retcomplex"> - <title>Returning complex values</title> - <simpara> + use RETURN_TRUE and RETURN_FALSE respectively.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-retcomplex"> + <title>Returning complex values</title> + <simpara> Your function can also return a complex data type such as an object or an array.</simpara> - - <para> + <para> Returning an object: <orderedlist numeration="arabic"> - <listitem><simpara>Call object_init(return_value).</simpara></listitem> - <listitem><para>Fill it up with values. The functions available - for this purpose are listed below.</para></listitem> - <listitem><para> Possibly, register functions for this object. + <listitem> + <simpara>Call object_init(return_value).</simpara> + </listitem> + <listitem> + <para>Fill it up with values. The functions available + for this purpose are listed below.</para> + </listitem> + <listitem> + <para> Possibly, register functions for this object. In order to obtain values from the object, the function would have to fetch "this" from the active_symbol_table. Its type should be IS_OBJECT, and it's basically a regular hash table @@ -397,85 +415,127 @@ actual registration of the function can be done using: <programlisting> add_method( return_value, function_name, function_ptr ); - </programlisting></para></listitem> - </orderedlist></para> - - <para> + </programlisting> + </para> + </listitem> + </orderedlist> + </para> + <para> The functions used to populate an object are: <itemizedlist> - <listitem><simpara>add_property_long( return_value, + <listitem> + <simpara>add_property_long( return_value, property_name, l ) - Add a property named 'property_name', of - type long, equal to 'l'</simpara></listitem> - <listitem><simpara>add_property_double( return_value, - property_name, d ) - Same, only adds a double</simpara></listitem> - <listitem><simpara>add_property_string( return_value, - property_name, str ) - Same, only adds a string</simpara></listitem> - <listitem><simpara>add_property_stringl( return_value, - property_name, str, l ) - Same, only adds a string of length 'l'</simpara></listitem> - </itemizedlist></para> - - <para> + type long, equal to 'l'</simpara> + </listitem> + <listitem> + <simpara>add_property_double( return_value, + property_name, d ) - Same, only adds a double</simpara> + </listitem> + <listitem> + <simpara>add_property_string( return_value, + property_name, str ) - Same, only adds a string</simpara> + </listitem> + <listitem> + <simpara>add_property_stringl( return_value, + property_name, str, l ) - Same, only adds a string of length 'l'</simpara> + </listitem> + </itemizedlist> + </para> + <para> Returning an array: <orderedlist numeration="arabic"> - <listitem><simpara>Call array_init(return_value).</simpara></listitem> - <listitem><simpara>Fill it up with values. The functions available - for this purpose are listed below.</simpara></listitem> - </orderedlist></para> - - <para> + <listitem> + <simpara>Call array_init(return_value).</simpara> + </listitem> + <listitem> + <simpara>Fill it up with values. The functions available + for this purpose are listed below.</simpara> + </listitem> + </orderedlist> + </para> + <para> The functions used to populate an array are: <itemizedlist> - <listitem><simpara>add_assoc_long(return_value,key,l) - add - associative entry with key 'key' and long value 'l'</simpara></listitem> - <listitem><simpara>add_assoc_double(return_value,key,d)</simpara></listitem> - <listitem><simpara>add_assoc_string(return_value,key,str,duplicate)</simpara></listitem> - <listitem><simpara>add_assoc_stringl(return_value,key,str,length,duplicate) - specify the string length</simpara></listitem> - <listitem><simpara>add_index_long(return_value,index,l) - add - entry in index 'index' with long value 'l'</simpara></listitem> - <listitem><simpara>add_index_double(return_value,index,d)</simpara></listitem> - <listitem><simpara>add_index_string(return_value,index,str)</simpara></listitem> - <listitem><simpara>add_index_stringl(return_value,index,str,length) - - specify the string length</simpara></listitem> - <listitem><simpara>add_next_index_long(return_value,l) - add an - array entry in the next free offset with long value 'l'</simpara></listitem> - <listitem><simpara>add_next_index_double(return_value,d)</simpara></listitem> - <listitem><simpara>add_next_index_string(return_value,str)</simpara></listitem> - <listitem><simpara>add_next_index_stringl(return_value,str,length) - - specify the string length</simpara></listitem> - </itemizedlist></para></sect2> - - <sect2 id="phpdevel-addfunc-reslist"> - <title>Using the resource list</title> - <simpara> + <listitem> + <simpara>add_assoc_long(return_value,key,l) - add + associative entry with key 'key' and long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_assoc_double(return_value,key,d)</simpara> + </listitem> + <listitem> + <simpara>add_assoc_string(return_value,key,str,duplicate)</simpara> + </listitem> + <listitem> + <simpara>add_assoc_stringl(return_value,key,str,length,duplicate) + specify the string length</simpara> + </listitem> + <listitem> + <simpara>add_index_long(return_value,index,l) - add + entry in index 'index' with long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_index_double(return_value,index,d)</simpara> + </listitem> + <listitem> + <simpara>add_index_string(return_value,index,str)</simpara> + </listitem> + <listitem> + <simpara>add_index_stringl(return_value,index,str,length) + - specify the string length</simpara> + </listitem> + <listitem> + <simpara>add_next_index_long(return_value,l) - add an + array entry in the next free offset with long value 'l'</simpara> + </listitem> + <listitem> + <simpara>add_next_index_double(return_value,d)</simpara> + </listitem> + <listitem> + <simpara>add_next_index_string(return_value,str)</simpara> + </listitem> + <listitem> + <simpara>add_next_index_stringl(return_value,str,length) + - specify the string length</simpara> + </listitem> + </itemizedlist> + </para> + </sect2> + <sect2 id="phpdevel-addfunc-reslist"> + <title>Using the resource list</title> + <simpara> PHP 3.0 has a standard way of dealing with various types of resources. This replaces all of the local linked lists in PHP 2.0.</simpara> - - <para> + <para> Available functions: <itemizedlist> - <listitem><simpara>php3_list_insert(ptr, type) - returns the 'id' - of the newly inserted resource</simpara></listitem> - <listitem><simpara>php3_list_delete(id) - delete the resource - with the specified id</simpara></listitem> - <listitem><simpara>php3_list_find(id,*type) + <listitem> + <simpara>php3_list_insert(ptr, type) - returns the 'id' + of the newly inserted resource</simpara> + </listitem> + <listitem> + <simpara>php3_list_delete(id) - delete the resource + with the specified id</simpara> + </listitem> + <listitem> + <simpara>php3_list_find(id,*type) - returns the pointer of the resource with the specified id, - updates 'type' to the resource's type</simpara></listitem> - </itemizedlist> + updates 'type' to the resource's type</simpara> + </listitem> + </itemizedlist> Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file descriptors.</para> - - <simpara> + <simpara> Typical list code would look like this:</simpara> - - <para> - <example> - <title>Adding a new resource</title> - <programlisting> + <para> + <example> + <title>Adding a new resource</title> + <programlisting> RESOURCE *resource; /* ...allocate memory for resource and acquire resource... */ @@ -483,11 +543,10 @@ return_value->value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE); return_value->type = IS_LONG; </programlisting> - </example> - - <example> - <title>Using an existing resource</title> - <programlisting> + </example> + <example> + <title>Using an existing resource</title> + <programlisting> pval *resource_id; RESOURCE *resource; int type; @@ -500,11 +559,10 @@ } /* ...use resource... */ </programlisting> - </example> - - <example> - <title>Deleting an existing resource</title> - <programlisting> + </example> + <example> + <title>Deleting an existing resource</title> + <programlisting> pval *resource_id; RESOURCE *resource; int type; @@ -512,17 +570,17 @@ convert_to_long(resource_id); php3_list_delete(resource_id->value.lval); </programlisting> - </example> + </example> The resource types should be registered in php3_list.h, in enum list_entry_type. In addition, one should add shutdown code for any new resource type defined, in list.c's list_entry_destructor() (even if you don't have anything to do on shutdown, you must add - an empty case).</para></sect2> - - <sect2 id="phpdevel-addfunc-prestable"> - <title>Using the persistent resource table</title> - <para> + an empty case).</para> + </sect2> + <sect2 id="phpdevel-addfunc-prestable"> + <title>Using the persistent resource table</title> + <para> PHP 3.0 has a standard way of storing persistent resources (i.e., resources that are kept in between hits). The first module to use this feature was the MySQL module, and mSQL followed it, so one @@ -530,17 +588,20 @@ be used by reading mysql.c. The functions you should look at are: <simplelist> - <member>php3_mysql_do_connect</member> - <member>php3_mysql_connect()</member> - <member>php3_mysql_pconnect()</member> - </simplelist></para> - - <para> + <member>php3_mysql_do_connect</member> + <member>php3_mysql_connect()</member> + <member>php3_mysql_pconnect()</member> + </simplelist> + </para> + <para> The general idea of persistence modules is this: <orderedlist numeration="arabic"> - <listitem><simpara>Code all of your module to work with the - regular resource list mentioned in section (9).</simpara></listitem> - <listitem><simpara>Code extra connect functions that check if the + <listitem> + <simpara>Code all of your module to work with the + regular resource list mentioned in section (9).</simpara> + </listitem> + <listitem> + <simpara>Code extra connect functions that check if the resource already exists in the persistent resource list. If it does, register it as in the regular resource list as a pointer to the persistent resource list (because of 1., the rest of the code @@ -551,30 +612,34 @@ resource would be found in the persistent resource list and be used without having to recreate it. You should register these resources with a different type (e.g. LE_MYSQL_LINK for - non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara></listitem> - </orderedlist></para> - - <simpara> + non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara> + </listitem> + </orderedlist> + </para> + <simpara> If you read mysql.c, you'll notice that except for the more complex connect function, nothing in the rest of the module has to be changed.</simpara> - - <simpara> + <simpara> The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with 'plist':</simpara> - - <itemizedlist> - <listitem><simpara>php3_plist_insert(ptr, type) - returns the 'id' - of the newly inserted resource</simpara></listitem> - <listitem><simpara>php3_plist_delete(id) - delete the resource - with the specified id</simpara></listitem> - <listitem><simpara>php3_plist_find(id,*type) + <itemizedlist> + <listitem> + <simpara>php3_plist_insert(ptr, type) - returns the 'id' + of the newly inserted resource</simpara> + </listitem> + <listitem> + <simpara>php3_plist_delete(id) - delete the resource + with the specified id</simpara> + </listitem> + <listitem> + <simpara>php3_plist_find(id,*type) - returns the pointer of the resource with the specified id, - updates 'type' to the resource's type</simpara></listitem> - </itemizedlist> - - <simpara> + updates 'type' to the resource's type</simpara> + </listitem> + </itemizedlist> + <simpara> However, it's more than likely that these functions would prove to be useless for you when trying to implement a persistent module. Typically, one would want to use the fact that the persistent @@ -585,12 +650,10 @@ this string as a key. The next time someone calls a pconnect() with the same host/user/passwd, the same key would be generated, and the function would find the SQL link in the persistent list.</simpara> - - <simpara> + <simpara> Until further documented, you should look at mysql.c or msql.c to see how one should use the plist's hash table abilities.</simpara> - - <simpara> + <simpara> One important thing to note: resources going into the persistent resource list must *NOT* be allocated with PHP's memory manager, i.e., they should NOT be created with emalloc(), estrdup(), etc. @@ -600,8 +663,7 @@ manager is deleted. Since the persistent list isn't supposed to be erased at the end of a request, one mustn't use PHP's memory manager for allocating resources that go to it.</simpara> - - <simpara> + <simpara> When you register a resource that's going to be in the persistent list, you should add destructors to it both in the non-persistent list and in the persistent list. The destructor in the @@ -612,12 +674,11 @@ every resource, even it requires no destructotion and the destructor would be empty. Remember, since emalloc() and friends aren't to be used in conjunction with the persistent list, you - mustn't use efree() here either.</simpara></sect2> - - - <sect2 id="phpdevel-addfunc-addcfg"> - <title>Adding runtime configuration directives</title> - <para> + mustn't use efree() here either.</simpara> + </sect2> + <sect2 id="phpdevel-addfunc-addcfg"> + <title>Adding runtime configuration directives</title> + <para> Many of the features of PHP 3 can be configured at runtime. These configuration directives can appear in either the designated php3.ini file, or in the case of the Apache module version in the @@ -627,73 +688,75 @@ safemodeexecdir for example, while another directory may have another. This configuration granularity is especially handy when a server supports multiple virtual hosts.</para> - - <para> + <para> The steps required to add a new directive: <orderedlist> - <listitem><simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara></listitem> - - <listitem><simpara>In main.c, edit the php3_module_startup + <listitem> + <simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara> + </listitem> + <listitem> + <simpara>In main.c, edit the php3_module_startup function and add the appropriate cfg_get_string() or - cfg_get_long() call.</simpara></listitem> - - <listitem><simpara>Add the directive, restrictions and a comment + cfg_get_long() call.</simpara> + </listitem> + <listitem> + <simpara>Add the directive, restrictions and a comment to the php3_commands structure in mod_php3.c. Note the restrictions part. RSRC_CONF are directives that can only be present in the actual Apache .conf files. Any OR_OPTIONS directives can be present anywhere, include normal .htaccess - files.</simpara></listitem> - - <listitem><simpara>In either php3take1handler() or - php3flaghandler() add the appropriate entry for your directive.</simpara></listitem> - - <listitem><simpara>In the configuration section of the + files.</simpara> + </listitem> + <listitem> + <simpara>In either php3take1handler() or + php3flaghandler() add the appropriate entry for your directive.</simpara> + </listitem> + <listitem> + <simpara>In the configuration section of the _php3_info() function in functions/info.c you need to add your - new directive.</simpara></listitem> - - <listitem><simpara>And last, you of course have to use your new + new directive.</simpara> + </listitem> + <listitem> + <simpara>And last, you of course have to use your new directive somewhere. It will be addressable as - php3_ini.directive.</simpara></listitem> - </orderedlist></para></sect2></sect1> - - - <sect1 id="calling-user-functions"> - <title>Calling User Functions</title> - - <simpara> + php3_ini.directive.</simpara> + </listitem> + </orderedlist> + </para> + </sect2> + </sect1> + <sect1 id="calling-user-functions"> + <title>Calling User Functions</title> + <simpara> To call user functions from an internal function, you should use the <function>call_user_function</function> function. </simpara> - - <simpara> - <function>call_user_function</function> returns SUCCESS on success, + <simpara> + <function>call_user_function</function> returns SUCCESS on success, and FAILURE in case the function cannot be found. You should check that return value! If it returns SUCCESS, you are responsible for destroying the retval pval yourself (or return it as the return value of your function). If it returns FAILURE, the value of retval is undefined, and you mustn't touch it. </simpara> - - <simpara> + <simpara> All internal functions that call user functions <emphasis>must</emphasis> be reentrant. Among other things, this means they must not use globals or static variables. </simpara> - - <simpara> - <function>call_user_function</function> takes six arguments: + <simpara> + <function>call_user_function</function> takes six arguments: </simpara> - - <sect2 id="calling-user-functions.function-table"> - <title>HashTable *function_table</title> - <simpara> + <sect2 id="calling-user-functions.function-table"> + <title>HashTable *function_table</title> + <simpara> This is the hash table in which the function is to be looked up. - </simpara></sect2> - - <sect2 id="calling-user-functions.object"> - <title>pval *object</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.object"> + <title>pval *object</title> + <simpara> This is a pointer to an object on which the function is invoked. This should be NULL if a global function is called. If it's not NULL (i.e. it points to an object), the function_table argument is @@ -701,48 +764,48 @@ be modified by the function that is invoked on it (that function will have access to it via $this). If for some reason you don't want that to happen, send a copy of the object instead. - </simpara></sect2> - - <sect2 id="calling-user-functions.function-name"> - <title>pval *function_name</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.function-name"> + <title>pval *function_name</title> + <simpara> The name of the function to call. Must be a pval of type IS_STRING with function_name.str.val and function_name.str.len set to the appropriate values. The function_name is modified by call_user_function() - it's converted to lowercase. If you need to preserve the case, send a copy of the function name instead. - </simpara></sect2> - - <sect2 id="calling-user-functions.retval"> - <title>pval *retval</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.retval"> + <title>pval *retval</title> + <simpara> A pointer to a pval structure, into which the return value of the invoked function is saved. The structure must be previously allocated - <function>call_user_function</function> does NOT allocate it by itself. - </simpara></sect2> - - <sect2 id="calling-user-functions.param-count"> - <title>int param_count</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.param-count"> + <title>int param_count</title> + <simpara> The number of parameters being passed to the function. - </simpara></sect2> - - <sect2 id="calling-user-functions.params"> - <title>pval *params[]</title> - <simpara> + </simpara> + </sect2> + <sect2 id="calling-user-functions.params"> + <title>pval *params[]</title> + <simpara> An array of pointers to values that will be passed as arguments to the function, the first argument being in offset 0, the second in offset 1, etc. The array is an array of pointers to pval's; The pointers are sent as-is to the function, which means if the function modifies its arguments, the original values are changed (passing by reference). If you don't want that behavior, pass a copy instead. - </simpara></sect2></sect1> - - <sect1 id="phpdevel-errors"> - <title>Reporting Errors</title> - - <simpara> + </simpara> + </sect2> + </sect1> + <sect1 id="phpdevel-errors"> + <title>Reporting Errors</title> + <simpara> To report errors from an internal function, you should call the <function>php3_error</function> function. This takes at least two parameters -- the first is the level of the error, the second is @@ -750,106 +813,94 @@ <function>printf</function> call), and any following arguments are the parameters for the format string. The error levels are: </simpara> - - <sect2 id="internal.e-notice"> - <title>E_NOTICE</title> - <simpara> + <sect2 id="internal.e-notice"> + <title>E_NOTICE</title> + <simpara> Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. For example, trying to access the value of a variable which has not been set, or calling <function>stat</function> on a file that doesn't exist. </simpara> - </sect2> - - <sect2 id="internal.e-warning"> - <title>E_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-warning"> + <title>E_WARNING</title> + <simpara> Warnings are printed by default, but do not interrupt script execution. These indicate a problem that should have been trapped by the script before the call was made. For example, calling <function>ereg</function> with an invalid regular expression. </simpara> - </sect2> - - <sect2 id="internal.e-error"> - <title>E_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-error"> + <title>E_ERROR</title> + <simpara> Errors are also printed by default, and execution of the script is halted after the function returns. These indicate errors that can not be recovered from, such as a memory allocation problem. </simpara> - </sect2> - - <sect2 id="internal.e-parse"> - <title>E_PARSE</title> - <simpara> + </sect2> + <sect2 id="internal.e-parse"> + <title>E_PARSE</title> + <simpara> Parse errors should only be generated by the parser. The code is listed here only for the sake of completeness. </simpara> - </sect2> - - <sect2 id="internal.e-core-error"> - <title>E_CORE_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-core-error"> + <title>E_CORE_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated by the core of PHP. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-core-warning"> - <title>E_CORE_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-core-warning"> + <title>E_CORE_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by the core of PHP. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-compile-error"> - <title>E_COMPILE_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-compile-error"> + <title>E_COMPILE_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-compile-warning"> - <title>E_COMPILE_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-compile-warning"> + <title>E_COMPILE_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by the Zend Scripting Engine. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-error"> - <title>E_USER_ERROR</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-error"> + <title>E_USER_ERROR</title> + <simpara> This is like an E_ERROR, except it is generated in PHP code by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-warning"> - <title>E_USER_WARNING</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-warning"> + <title>E_USER_WARNING</title> + <simpara> This is like an E_WARNING, except it is generated by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - <sect2 id="internal.e-user-notice"> - <title>E_USER_NOTICE</title> - <simpara> + </sect2> + <sect2 id="internal.e-user-notice"> + <title>E_USER_NOTICE</title> + <simpara> This is like an E_NOTICE, except it is generated by using the PHP function <function>trigger_error</function>. Functions should not generate this type of error. </simpara> - </sect2> - - </sect1> - </appendix> + </sect2> + </sect1> +</appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml