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