cvs: phpdoc-zh /appendices phpdevel.xml
| From: | Dallas Thunder | Date: | Thu, 11 Aug 2005 01:06:23 +0000 |
| Subject: | cvs: phpdoc-zh /appendices phpdevel.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-2146@lists.php.net to get a copy of this message | ||
dallas Wed Aug 10 21:06:23 2005 EDT
Modified files:
/phpdoc-zh/appendices phpdevel.xml
Log:
Updated yet still not finished.
http://cvs.php.net/diff.php/phpdoc-zh/appendices/phpdevel.xml?r1=1.25&r2=1.26&ty=u Index: phpdoc-zh/appendices/phpdevel.xml diff -u phpdoc-zh/appendices/phpdevel.xml:1.25 phpdoc-zh/appendices/phpdevel.xml:1.26 --- phpdoc-zh/appendices/phpdevel.xml:1.25 Tue May 27 02:34:41 2003 +++ phpdoc-zh/appendices/phpdevel.xml Wed Aug 10 21:06:19 2005 @@ -1,16 +1,18 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.25 $ --> -<!-- $Author: gregory $ --> -<!-- EN-Revision: 1.24 Maintainer: class007 Status: working --> +<!-- $Revision: 1.26 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.26 Maintainer: class007 Status: partial --> <!-- CREDITS: dallas --> <appendix id="phpdevel"> <title>À©Õ¹ PHP 3</title> - <simpara> - ¸ÃÕ½ÚÖеÄÄÚÈÝ¿ÉÄÜÒѾ±È½Ï¹ýʱÁË£¬Ëü½²½âÁËÈçºÎÀ©Õ¹ PHP3¡£Èç¹ûÄú¶Ô PHP 4 ¸ÐÐËȤ£¬ÇëÔĶÁ¡°<link linkend="zend">Zend API</link>¡±µÄÓйØÕ½ڡ£Í¬Ê±£¬Äú»¹¿ÉÒÔÔĶÁ PHP Ô´ÎĵµÖеÄһЩÎĵµ£¬ÀýÈç - <filename>README.SELF-CONTAINED-EXTENSIONS</filename> ºÍ + <simpara> + ¸ÃÕ½ÚÖеÄÄÚÈÝ¿ÉÄÜÒѾ±È½Ï¹ýʱÁË£¬Ëü½²½âÁËÈçºÎÀ©Õ¹ PHP3¡£Èç¹ûÄú¶Ô PHP 4 + ¸ÐÐËȤ£¬ÇëÔĶÁ¡°<link linkend="zend">Zend API</link>¡±µÄÓйØÕ½ڡ£Í¬Ê±£¬Äú»¹¿ÉÒÔÔĶÁ + PHP Ô´ÎĵµÖеÄһЩÎĵµ£¬ÀýÈç + <filename>README.SELF-CONTAINED-EXTENSIONS</filename> ºÍ <filename>README.EXT_SKEL</filename>¡£ - </simpara> + </simpara> <sect1 id="phpdevel-addfunc"> <title>Ϊ PHP ÐÂÔöº¯Êý</title> @@ -18,10 +20,10 @@ <title>º¯ÊýÔÐÍ</title> <para> ËùÓеĺ¯ÊýÓÐ×ÅÈçÏÂÐÎʽ£º - <programlisting role="c"> + <programlisting role="c"> <![CDATA[ void php3_foo(INTERNAL_FUNCTION_PARAMETERS) { - + } ]]> </programlisting> @@ -47,13 +49,13 @@ ]]> </programlisting> </example> - + ×¢Ò⣺²ÎÊý¼È¿ÉÒÔ±»Öµ£¨value£©´«µÝÓÖ¿ÉÒÔ±»ÒýÓã¨reference£©´«µÝ¡£Á½ÖÖÇé¿öÄú¶¼ÐèÒª½« &(pval *) ´«µÝ¸ø getParameters º¯Êý¡£Èç¹ûÄúÏë¼ì²éµÚ n ¸ö²ÎÊýÊÇ·ñͨ¹ýÒýÓô«µÝ¸øÄú£¬Äú¿ÉÒÔʹÓà ParameterPassedByReference(ht,n) º¯Êý¡£ËüµÄ·µ»ØÖµÎª 0 »òÕß 1¡£ </para> - + <simpara> µ±Äú¸Ä±äÁËÈκÎÒÑ´«µÝµÄ²ÎÊý£¬ÎÞÂÛËüÃÇÊÇÒÔÖµ»òÕßÒýÓõķ½Ê½´«µÝ£¬Äú¶¼¿ÉÒÔ¶ÔËüʹÓà pval_destructor º¯ÊýÀ´Ïú»ÙËü¡£»òÕßÈç¹ûËüÊÇÒ»¸öÄúÏëÌí¼ÓµÄÊý×飬Äú¿ÉÒÔʹÓÃÀàËÆÓÚ @@ -66,13 +68,13 @@ IS_STRING »ò IS_ARRAY µÄ²ÎÊýÓ¦¸ÃÏÈ¶ÔÆäÔËÐÐ pval_destructor¡£ </simpara> </sect2> - + <sect2 id="phpdevel-addfunc-varargs"> <title>¿É±äº¯Êý²ÎÊý</title> <para> º¯Êý¿ÉÒÔ½ÓÊܲ»Í¬ÊýÄ¿µÄ²ÎÊý¡£Èç¹ûÄãµÄº¯Êý¿ÉÒÔ½ÓÊÜ 2 »ò 3 ¸ö²ÎÊý£¬ÕâÑùÓ㺠</para> - + <para> <example> <title>¿É±äº¯Êý²ÎÊý</title> @@ -90,7 +92,7 @@ </example> </para> </sect2> - + <sect2 id="phpdevel-addfunc-using-args"> <title>ʹÓú¯Êý²ÎÊý</title> <para> @@ -145,12 +147,12 @@ <![CDATA[ convert_to_long(arg1); convert_to_double(arg1); -convert_to_string(arg1); +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> ÕâЩº¯Êý¶¼ÊǼ´Ê±×ª»»µÄ£¬²¢²»·µ»ØÈκÎÖµ¡£ </simpara> @@ -162,7 +164,7 @@ <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>º¯ÊýÖеÄÄÚ´æ¹ÜÀí</title> <simpara> @@ -205,21 +207,21 @@ ҪעÒâ SET_VAR_STRING¡£ÖµµÄ²¿·Ö±ØÐëÊÇÈ˹¤·ÖÅä³öÀ´µÄ£¬ÒòΪÄÚ´æ¹ÜÀí´úÂë»áÔÚÒÔºó³¢ÊÔÊͷŸÃÖ¸Õë¡£²»Òª½«¾²Ì¬·ÖÅäµÄÄÚ´æ´«µÝ¸ø SET_VAR_STRING¡£ </para> </warning> - + <simpara> PHP ÖеķûºÅ±íÊÇÒÔÉ¢ÁбíÀ´ÊµÏֵġ£ÈκÎʱºò &symbol_table ¶¼ÊÇÒ»¸öÖ¸Ïò 'main' ·ûºÅ±íµÄÖ¸Õ룬active_symbol_table points Ö¸Ïòµ±Ç°»î¶¯µÄ·ûºÅ±í£¨¶þÕßÔÚ¿ªÊ¼Ê±µÈͬ£¬¶øÔÚº¯ÊýÄÚ²»Í¬£©¡£ </simpara> - + <para> ÒÔÏÂÀý×ÓʹÓÃÁË 'active_symbol_table'¡£Èç¹ûÄãÖ¸Ã÷Òª¹¤×÷ÓÚ 'main' ·ûºÅ±í£¬Ó¦¸ÃÓà &symbol_table À´Ìæ´ú¡£´ËÍ⣬ͬÑùµÄº¯ÊýÒ²ÄÜÏñÏÂÃæËµÃ÷µÄ×÷ÓÃÓÚÊý×é¡£ </para> - + <para> <example> - <title>¼ì²é $foo ÊÇ·ñ´æÔÚÓÚ·ûºÅ±í</title> + <title>¼ì²é <varname>$foo</varname> ÊÇ·ñ´æÔÚÓÚ·ûºÅ±í</title> <programlisting role="c"> <![CDATA[ if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... } @@ -237,10 +239,9 @@ ]]> </programlisting> </example> - PHP ÖеÄÊý×éʹÓÃÁ˺ͷûºÅ±íͬһ¸öÉ¢ÁбíÀ´ÊµÏÖ¡£ÕâÒâζ×ÅÒÔÉÏÁ½¸öº¯ÊýÒ²¿ÉÒÔÓÃÀ´¼ì²éÊý×éÖеıäÁ¿¡£ </para> - + <simpara> Èç¹ûÒªÔÚ·ûºÅ±íÖж¨ÒåÒ»¸öÐÂÊý×飬Ӧ¸ÃÕâÑù×ö¡£ </simpara> @@ -252,50 +253,49 @@ <simpara> ½Ó×Å£¬³õʼ»¯Êý×飺 </simpara> - + <para> <example> <title>³õʼ»¯ÐÂÊý×é</title> <programlisting role="c"> <![CDATA[ pval arr; - + if (array_init(&arr) == FAILURE) { failed... }; hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL); ]]> </programlisting> </example> - - Õâ¶Î´úÂëÔڻ·ûºÅ±íÖж¨ÒåÁËÒ»¸öÃûΪ $foo µÄÐÂÊý×é¡£ÕâÊǸö¿ÕÊý×é¡£ + Õâ¶Î´úÂëÔڻ·ûºÅ±íÖж¨ÒåÁËÒ»¸öÃûΪ <varname>$foo</varname> µÄÐÂÊý×é¡£ÕâÊǸö¿ÕÊý×é¡£ </para> - + <simpara> ÕâÀïչʾÁËÔõÑùÏòÆäÖмÓÈëеÄÌõÄ¿£º</simpara> - + <para> <example> <title>ÏòÊý×éÖмÓÈëеÄÌõÄ¿</title> <programlisting role="c"> <![CDATA[ pval entry; - + entry.type = IS_LONG; entry.value.lval = 5; - + /* defines $foo["bar"] = 5 */ -hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); +hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); /* defines $foo[7] = 5 */ -hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); +hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); /* defines the next free place in $foo[], * $foo[8], to be 5 (works like php2) */ -hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); +hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); ]]> </programlisting> </example> - + Èç¹ûÒªÐÞ¸ÄÒ»¸ö²åÈ뵽ɢÁбíÖеÄÖµ£¬±ØÐëÏȽ«ÆäÌáÈ¡³öÀ´¡£Òª±ÜÃâ¶îÍ⿪ÏúÄã¿ÉÒÔ¸ø hash add º¯ÊýÌṩһ¸ö pval ** ²ÎÊý£¬Ëü½«±»±íÖÐÏàÓ¦µ¥ÔªµÄ pval * µØÖ·Ëù¸üС£Èç¹ûÆäֵΪ &null;£¨ÈçͬÒÔÉÏËùÓеÄÀý×Ó£©£¬¸Ã²ÎÊý±»ºöÂÔ¡£ @@ -303,7 +303,8 @@ <simpara> hash_next_index_insert() »ò¶à»òÉÙʹÓÃÁËÈçͬ PHP 2.0 ÖÐ - "$foo[] = bar;" µÄÂß¼¡£</simpara> + <literal>"$foo[] = bar;"</literal> µÄÂß¼¡£ + </simpara> <simpara> Èç¹ûÒª½¨Á¢Ò»¸ö´Óº¯Êý·µ»ØµÄÊý×飬¿ÉÒÔ¾ÍÏñÒÔÉÏÄÇÑù³õʼ»¯Êý×飺 @@ -325,14 +326,14 @@ add_next_index_string(return_value,estrdup(string_value)); ]]> </programlisting> - + <para> µ±È»ÁË£¬Èç¹ûÈç¹ûÔÚÊý×é³õʼ»¯ºóÌí¼Ó²»ÕýÈ·£¬ÄãÓ¦¸ÃÏȲ鿴һÏÂÊý×飺 - + <programlisting role="c"> <![CDATA[ pval *arr; - + if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... } else { use arr->value.ht... } ]]> @@ -341,18 +342,18 @@ <simpara> ×¢Òâ hash_find ½ÓÊÜÒ»¸öÖ¸Ïò pval Ö¸ÕëµÄÖ¸Õ룬²¢²»ÊÇ pval Ö¸Õë¡£ </simpara> - + <simpara> ÒÔÉÏÈκΠhash º¯Êý·µ»Ø SUCCESS »ò FAILURE£¨³ýÁË hash_exists()£¬Ëü·µ»ØÒ»¸ö²¼¶ûÕæÖµ£©¡£ </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> + function easier.</simpara> <para> The RETURN_* macros all set the return value and return from the @@ -366,7 +367,7 @@ <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> @@ -386,7 +387,7 @@ <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> @@ -411,15 +412,17 @@ add_method( return_value, function_name, function_ptr ); ]]> </programlisting> - </para></listitem> - </orderedlist></para> + </para> + </listitem> + </orderedlist> + </para> <para> The functions used to populate an object are: <itemizedlist> <listitem><simpara>add_property_long( return_value, property_name, l ) - Add a property named 'property_name', of - type long, equal to 'l'</simpara></listitem> + 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, @@ -430,7 +433,7 @@ <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 @@ -473,7 +476,7 @@ <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> + 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> @@ -481,11 +484,12 @@ Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file - descriptors.</para> + descriptors. + </para> <simpara> Typical list code would look like this:</simpara> - + <para> <example> <title>Adding a new resource</title> @@ -512,8 +516,8 @@ convert_to_long(resource_id); resource = php3_list_find(resource_id->value.lval, &type); if (type != LE_RESOURCE_TYPE) { - php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval); - RETURN_FALSE; + php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval); + RETURN_FALSE; } /* ...use resource... */ ]]> @@ -533,7 +537,7 @@ ]]> </programlisting> </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() @@ -578,7 +582,7 @@ 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> The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with @@ -588,7 +592,7 @@ <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> + 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> @@ -652,8 +656,8 @@ 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>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> @@ -772,7 +776,7 @@ </simpara> <sect2 id="internal.e-notice"> - <title>E_NOTICE</title> + <title><constant>E_NOTICE</constant></title> <simpara> Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also @@ -783,17 +787,17 @@ </sect2> <sect2 id="internal.e-warning"> - <title>E_WARNING</title> + <title><constant>E_WARNING</constant></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. + 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> + <title><constant>E_ERROR</constant></title> <simpara> Errors are also printed by default, and execution of the script is halted after the function returns. These indicate errors that can @@ -802,7 +806,7 @@ </sect2> <sect2 id="internal.e-parse"> - <title>E_PARSE</title> + <title><constant>E_PARSE</constant></title> <simpara> Parse errors should only be generated by the parser. The code is listed here only for the sake of completeness. @@ -810,68 +814,68 @@ </sect2> <sect2 id="internal.e-core-error"> - <title>E_CORE_ERROR</title> + <title><constant>E_CORE_ERROR</constant></title> <simpara> - This is like an E_ERROR, except it is generated by the core + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_CORE_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by the core + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_COMPILE_ERROR</constant></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. + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_COMPILE_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by the Zend Scripting + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_USER_ERROR</constant></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 + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_USER_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_USER_NOTICE</constant></title> <simpara> - This is like an E_NOTICE, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not + This is like an <constant>E_NOTICE</constant>, 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-all"> - <title>E_ALL</title> + <title><constant>E_ALL</constant></title> <simpara> - All of the above. Using this error_reporting level will show + All of the above. Using this error_reporting level will show all error types. </simpara> </sect2>
http://cvs.php.net/diff.php/phpdoc-zh/appendices/phpdevel.xml?r1=1.25&r2=1.26&ty=u Index: phpdoc-zh/appendices/phpdevel.xml diff -u phpdoc-zh/appendices/phpdevel.xml:1.25 phpdoc-zh/appendices/phpdevel.xml:1.26 --- phpdoc-zh/appendices/phpdevel.xml:1.25 Tue May 27 02:34:41 2003 +++ phpdoc-zh/appendices/phpdevel.xml Wed Aug 10 21:06:19 2005 @@ -1,16 +1,18 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.25 $ --> -<!-- $Author: gregory $ --> -<!-- EN-Revision: 1.24 Maintainer: class007 Status: working --> +<!-- $Revision: 1.26 $ --> +<!-- $Author: dallas $ --> +<!-- EN-Revision: 1.26 Maintainer: class007 Status: partial --> <!-- CREDITS: dallas --> <appendix id="phpdevel"> <title>À©Õ¹ PHP 3</title> - <simpara> - ¸ÃÕ½ÚÖеÄÄÚÈÝ¿ÉÄÜÒѾ±È½Ï¹ýʱÁË£¬Ëü½²½âÁËÈçºÎÀ©Õ¹ PHP3¡£Èç¹ûÄú¶Ô PHP 4 ¸ÐÐËȤ£¬ÇëÔĶÁ¡°<link linkend="zend">Zend API</link>¡±µÄÓйØÕ½ڡ£Í¬Ê±£¬Äú»¹¿ÉÒÔÔĶÁ PHP Ô´ÎĵµÖеÄһЩÎĵµ£¬ÀýÈç - <filename>README.SELF-CONTAINED-EXTENSIONS</filename> ºÍ + <simpara> + ¸ÃÕ½ÚÖеÄÄÚÈÝ¿ÉÄÜÒѾ±È½Ï¹ýʱÁË£¬Ëü½²½âÁËÈçºÎÀ©Õ¹ PHP3¡£Èç¹ûÄú¶Ô PHP 4 + ¸ÐÐËȤ£¬ÇëÔĶÁ¡°<link linkend="zend">Zend API</link>¡±µÄÓйØÕ½ڡ£Í¬Ê±£¬Äú»¹¿ÉÒÔÔĶÁ + PHP Ô´ÎĵµÖеÄһЩÎĵµ£¬ÀýÈç + <filename>README.SELF-CONTAINED-EXTENSIONS</filename> ºÍ <filename>README.EXT_SKEL</filename>¡£ - </simpara> + </simpara> <sect1 id="phpdevel-addfunc"> <title>Ϊ PHP ÐÂÔöº¯Êý</title> @@ -18,10 +20,10 @@ <title>º¯ÊýÔÐÍ</title> <para> ËùÓеĺ¯ÊýÓÐ×ÅÈçÏÂÐÎʽ£º - <programlisting role="c"> + <programlisting role="c"> <![CDATA[ void php3_foo(INTERNAL_FUNCTION_PARAMETERS) { - + } ]]> </programlisting> @@ -47,13 +49,13 @@ ]]> </programlisting> </example> - + ×¢Ò⣺²ÎÊý¼È¿ÉÒÔ±»Öµ£¨value£©´«µÝÓÖ¿ÉÒÔ±»ÒýÓã¨reference£©´«µÝ¡£Á½ÖÖÇé¿öÄú¶¼ÐèÒª½« &(pval *) ´«µÝ¸ø getParameters º¯Êý¡£Èç¹ûÄúÏë¼ì²éµÚ n ¸ö²ÎÊýÊÇ·ñͨ¹ýÒýÓô«µÝ¸øÄú£¬Äú¿ÉÒÔʹÓà ParameterPassedByReference(ht,n) º¯Êý¡£ËüµÄ·µ»ØÖµÎª 0 »òÕß 1¡£ </para> - + <simpara> µ±Äú¸Ä±äÁËÈκÎÒÑ´«µÝµÄ²ÎÊý£¬ÎÞÂÛËüÃÇÊÇÒÔÖµ»òÕßÒýÓõķ½Ê½´«µÝ£¬Äú¶¼¿ÉÒÔ¶ÔËüʹÓà pval_destructor º¯ÊýÀ´Ïú»ÙËü¡£»òÕßÈç¹ûËüÊÇÒ»¸öÄúÏëÌí¼ÓµÄÊý×飬Äú¿ÉÒÔʹÓÃÀàËÆÓÚ @@ -66,13 +68,13 @@ IS_STRING »ò IS_ARRAY µÄ²ÎÊýÓ¦¸ÃÏÈ¶ÔÆäÔËÐÐ pval_destructor¡£ </simpara> </sect2> - + <sect2 id="phpdevel-addfunc-varargs"> <title>¿É±äº¯Êý²ÎÊý</title> <para> º¯Êý¿ÉÒÔ½ÓÊܲ»Í¬ÊýÄ¿µÄ²ÎÊý¡£Èç¹ûÄãµÄº¯Êý¿ÉÒÔ½ÓÊÜ 2 »ò 3 ¸ö²ÎÊý£¬ÕâÑùÓ㺠</para> - + <para> <example> <title>¿É±äº¯Êý²ÎÊý</title> @@ -90,7 +92,7 @@ </example> </para> </sect2> - + <sect2 id="phpdevel-addfunc-using-args"> <title>ʹÓú¯Êý²ÎÊý</title> <para> @@ -145,12 +147,12 @@ <![CDATA[ convert_to_long(arg1); convert_to_double(arg1); -convert_to_string(arg1); +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> ÕâЩº¯Êý¶¼ÊǼ´Ê±×ª»»µÄ£¬²¢²»·µ»ØÈκÎÖµ¡£ </simpara> @@ -162,7 +164,7 @@ <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>º¯ÊýÖеÄÄÚ´æ¹ÜÀí</title> <simpara> @@ -205,21 +207,21 @@ ҪעÒâ SET_VAR_STRING¡£ÖµµÄ²¿·Ö±ØÐëÊÇÈ˹¤·ÖÅä³öÀ´µÄ£¬ÒòΪÄÚ´æ¹ÜÀí´úÂë»áÔÚÒÔºó³¢ÊÔÊͷŸÃÖ¸Õë¡£²»Òª½«¾²Ì¬·ÖÅäµÄÄÚ´æ´«µÝ¸ø SET_VAR_STRING¡£ </para> </warning> - + <simpara> PHP ÖеķûºÅ±íÊÇÒÔÉ¢ÁбíÀ´ÊµÏֵġ£ÈκÎʱºò &symbol_table ¶¼ÊÇÒ»¸öÖ¸Ïò 'main' ·ûºÅ±íµÄÖ¸Õ룬active_symbol_table points Ö¸Ïòµ±Ç°»î¶¯µÄ·ûºÅ±í£¨¶þÕßÔÚ¿ªÊ¼Ê±µÈͬ£¬¶øÔÚº¯ÊýÄÚ²»Í¬£©¡£ </simpara> - + <para> ÒÔÏÂÀý×ÓʹÓÃÁË 'active_symbol_table'¡£Èç¹ûÄãÖ¸Ã÷Òª¹¤×÷ÓÚ 'main' ·ûºÅ±í£¬Ó¦¸ÃÓà &symbol_table À´Ìæ´ú¡£´ËÍ⣬ͬÑùµÄº¯ÊýÒ²ÄÜÏñÏÂÃæËµÃ÷µÄ×÷ÓÃÓÚÊý×é¡£ </para> - + <para> <example> - <title>¼ì²é $foo ÊÇ·ñ´æÔÚÓÚ·ûºÅ±í</title> + <title>¼ì²é <varname>$foo</varname> ÊÇ·ñ´æÔÚÓÚ·ûºÅ±í</title> <programlisting role="c"> <![CDATA[ if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... } @@ -237,10 +239,9 @@ ]]> </programlisting> </example> - PHP ÖеÄÊý×éʹÓÃÁ˺ͷûºÅ±íͬһ¸öÉ¢ÁбíÀ´ÊµÏÖ¡£ÕâÒâζ×ÅÒÔÉÏÁ½¸öº¯ÊýÒ²¿ÉÒÔÓÃÀ´¼ì²éÊý×éÖеıäÁ¿¡£ </para> - + <simpara> Èç¹ûÒªÔÚ·ûºÅ±íÖж¨ÒåÒ»¸öÐÂÊý×飬Ӧ¸ÃÕâÑù×ö¡£ </simpara> @@ -252,50 +253,49 @@ <simpara> ½Ó×Å£¬³õʼ»¯Êý×飺 </simpara> - + <para> <example> <title>³õʼ»¯ÐÂÊý×é</title> <programlisting role="c"> <![CDATA[ pval arr; - + if (array_init(&arr) == FAILURE) { failed... }; hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL); ]]> </programlisting> </example> - - Õâ¶Î´úÂëÔڻ·ûºÅ±íÖж¨ÒåÁËÒ»¸öÃûΪ $foo µÄÐÂÊý×é¡£ÕâÊǸö¿ÕÊý×é¡£ + Õâ¶Î´úÂëÔڻ·ûºÅ±íÖж¨ÒåÁËÒ»¸öÃûΪ <varname>$foo</varname> µÄÐÂÊý×é¡£ÕâÊǸö¿ÕÊý×é¡£ </para> - + <simpara> ÕâÀïչʾÁËÔõÑùÏòÆäÖмÓÈëеÄÌõÄ¿£º</simpara> - + <para> <example> <title>ÏòÊý×éÖмÓÈëеÄÌõÄ¿</title> <programlisting role="c"> <![CDATA[ pval entry; - + entry.type = IS_LONG; entry.value.lval = 5; - + /* defines $foo["bar"] = 5 */ -hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); +hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); /* defines $foo[7] = 5 */ -hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); +hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); /* defines the next free place in $foo[], * $foo[8], to be 5 (works like php2) */ -hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); +hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); ]]> </programlisting> </example> - + Èç¹ûÒªÐÞ¸ÄÒ»¸ö²åÈ뵽ɢÁбíÖеÄÖµ£¬±ØÐëÏȽ«ÆäÌáÈ¡³öÀ´¡£Òª±ÜÃâ¶îÍ⿪ÏúÄã¿ÉÒÔ¸ø hash add º¯ÊýÌṩһ¸ö pval ** ²ÎÊý£¬Ëü½«±»±íÖÐÏàÓ¦µ¥ÔªµÄ pval * µØÖ·Ëù¸üС£Èç¹ûÆäֵΪ &null;£¨ÈçͬÒÔÉÏËùÓеÄÀý×Ó£©£¬¸Ã²ÎÊý±»ºöÂÔ¡£ @@ -303,7 +303,8 @@ <simpara> hash_next_index_insert() »ò¶à»òÉÙʹÓÃÁËÈçͬ PHP 2.0 ÖÐ - "$foo[] = bar;" µÄÂß¼¡£</simpara> + <literal>"$foo[] = bar;"</literal> µÄÂß¼¡£ + </simpara> <simpara> Èç¹ûÒª½¨Á¢Ò»¸ö´Óº¯Êý·µ»ØµÄÊý×飬¿ÉÒÔ¾ÍÏñÒÔÉÏÄÇÑù³õʼ»¯Êý×飺 @@ -325,14 +326,14 @@ add_next_index_string(return_value,estrdup(string_value)); ]]> </programlisting> - + <para> µ±È»ÁË£¬Èç¹ûÈç¹ûÔÚÊý×é³õʼ»¯ºóÌí¼Ó²»ÕýÈ·£¬ÄãÓ¦¸ÃÏȲ鿴һÏÂÊý×飺 - + <programlisting role="c"> <![CDATA[ pval *arr; - + if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... } else { use arr->value.ht... } ]]> @@ -341,18 +342,18 @@ <simpara> ×¢Òâ hash_find ½ÓÊÜÒ»¸öÖ¸Ïò pval Ö¸ÕëµÄÖ¸Õ룬²¢²»ÊÇ pval Ö¸Õë¡£ </simpara> - + <simpara> ÒÔÉÏÈκΠhash º¯Êý·µ»Ø SUCCESS »ò FAILURE£¨³ýÁË hash_exists()£¬Ëü·µ»ØÒ»¸ö²¼¶ûÕæÖµ£©¡£ </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> + function easier.</simpara> <para> The RETURN_* macros all set the return value and return from the @@ -366,7 +367,7 @@ <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> @@ -386,7 +387,7 @@ <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> @@ -411,15 +412,17 @@ add_method( return_value, function_name, function_ptr ); ]]> </programlisting> - </para></listitem> - </orderedlist></para> + </para> + </listitem> + </orderedlist> + </para> <para> The functions used to populate an object are: <itemizedlist> <listitem><simpara>add_property_long( return_value, property_name, l ) - Add a property named 'property_name', of - type long, equal to 'l'</simpara></listitem> + 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, @@ -430,7 +433,7 @@ <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 @@ -473,7 +476,7 @@ <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> + 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> @@ -481,11 +484,12 @@ Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file - descriptors.</para> + descriptors. + </para> <simpara> Typical list code would look like this:</simpara> - + <para> <example> <title>Adding a new resource</title> @@ -512,8 +516,8 @@ convert_to_long(resource_id); resource = php3_list_find(resource_id->value.lval, &type); if (type != LE_RESOURCE_TYPE) { - php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval); - RETURN_FALSE; + php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval); + RETURN_FALSE; } /* ...use resource... */ ]]> @@ -533,7 +537,7 @@ ]]> </programlisting> </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() @@ -578,7 +582,7 @@ 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> The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with @@ -588,7 +592,7 @@ <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> + 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> @@ -652,8 +656,8 @@ 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>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> @@ -772,7 +776,7 @@ </simpara> <sect2 id="internal.e-notice"> - <title>E_NOTICE</title> + <title><constant>E_NOTICE</constant></title> <simpara> Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also @@ -783,17 +787,17 @@ </sect2> <sect2 id="internal.e-warning"> - <title>E_WARNING</title> + <title><constant>E_WARNING</constant></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. + 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> + <title><constant>E_ERROR</constant></title> <simpara> Errors are also printed by default, and execution of the script is halted after the function returns. These indicate errors that can @@ -802,7 +806,7 @@ </sect2> <sect2 id="internal.e-parse"> - <title>E_PARSE</title> + <title><constant>E_PARSE</constant></title> <simpara> Parse errors should only be generated by the parser. The code is listed here only for the sake of completeness. @@ -810,68 +814,68 @@ </sect2> <sect2 id="internal.e-core-error"> - <title>E_CORE_ERROR</title> + <title><constant>E_CORE_ERROR</constant></title> <simpara> - This is like an E_ERROR, except it is generated by the core + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_CORE_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by the core + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_COMPILE_ERROR</constant></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. + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_COMPILE_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by the Zend Scripting + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_USER_ERROR</constant></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 + This is like an <constant>E_ERROR</constant>, 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> + <title><constant>E_USER_WARNING</constant></title> <simpara> - This is like an E_WARNING, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not + This is like an <constant>E_WARNING</constant>, 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> + <title><constant>E_USER_NOTICE</constant></title> <simpara> - This is like an E_NOTICE, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not + This is like an <constant>E_NOTICE</constant>, 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-all"> - <title>E_ALL</title> + <title><constant>E_ALL</constant></title> <simpara> - All of the above. Using this error_reporting level will show + All of the above. Using this error_reporting level will show all error types. </simpara> </sect2>