cvs: phpdoc-ar /language types.xml
| From: | Hafid Benhadria | Date: | Mon, 22 Sep 2003 03:46:33 +0000 |
| Subject: | cvs: phpdoc-ar /language types.xml | ||
| Groups: | php.doc.ar | ||
| Request: | Send a blank email to doc-ar+get-575@lists.php.net to get a copy of this message | ||
hafid Sun Sep 21 23:46:33 2003 EDT
Modified files:
/phpdoc-ar/language types.xml
Log:
Final and Complete Translation. Still 1.123 compliant.
Index: phpdoc-ar/language/types.xml diff -u phpdoc-ar/language/types.xml:1.7 phpdoc-ar/language/types.xml:1.8 --- phpdoc-ar/language/types.xml:1.7 Sat Sep 20 01:58:49 2003 +++ phpdoc-ar/language/types.xml Sun Sep 21 23:46:33 2003 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-6"?> -<!-- $Revision: 1.7 $ --> -<!-- EN-Revision: 1.123 Maintainer: hafid Status: working --> +<!-- $Revision: 1.8 $ --> +<!-- EN-Revision: 1.123 Maintainer: hafid Status: ready --> <chapter id="language.types"> <title>ÇäÃæèÇÙ</title> <sect1 id="language.types.intro"> @@ -145,7 +145,6 @@ ÈÇÙÊÈÇÑ ÃæçÇ ÊØçÑ ÃåËäÉ äåâÇÑæÇÊ åÊÙäâÉ ÈÃæèÇÙ åÊÙÏÏÉ. </simpara> </sect1> - <sect1 id="language.types.boolean"> <title>Booleans - Çäåæ×âêÇÊ</title> <simpara> @@ -1910,17 +1909,17 @@ <sect2 id="language.types.object.casting"> <title>ÇäÊñÍèêä Åäé ãÇÆæ</title> <para> - If an object is converted to an object, it is not modified. If a value - of any other type is converted to an object, a new instance of the - <literal>stdClass</literal> built in class is created. If the value - was null, the new instance will be empty. For any other value, a - member variable named <literal>scalar</literal> will contain the - value. + ÅÐÇ Íïèñðä ãÇÆæ åÇ Åäé ãÇÆæ ÂÎѬ áÅæñç äÇ êïÙÏñîä. ÅÐÇ ÍïèñðäÊ âêåÉ + Ãê æèÙ ÂÎÑ Åäé ãÇÆæ¬ áÅæñç êÊå ÅæÔÇÁ åËêäí ÌÏêÏ + äÕæá <literal>stdClass</literal> ÇäåïÊÖñîåæ ÙæÏ ÇäÊñÔêêÏ. ÅÐÇ ãÇæÊ ÇäâêåÉ + null¬ áÅæñ ÇäåËêä ÇäÌÏêÏ Óêãèæ áÇÑÚÇë. ÈÇäæñÓÈÉ äÃêñ âêåÉ ÃÎÑé¬ áÅæñ + åïÊîÚîêñðÑ ÙÖèêñ êïÏòÙîé <literal>scalar</literal> ÓêÊÖåæ + ÇäâêåÉ. <informalexample> <programlisting role="php"><![CDATA[ <?php $obj = (object) 'ciao'; -echo $obj->scalar; // outputs 'ciao' +echo $obj->scalar; // êïÎÑÌ 'ciao' ?> ]]></programlisting> </informalexample> @@ -1928,46 +1927,46 @@ </sect2> </sect1> <sect1 id="language.types.resource"> - <title>Resource</title> + <title>ÇäåèÑÏ</title> <para> - A resource is a special variable, holding - a reference to an external resource. Resources - are created and used by special functions. - See the <link linkend="resource">appendix</link> - for a listing of all these - functions and the corresponding resource types. + ÇäåèÑÏ çè åïÊîÚîêñðÑ ÎÇÕ êÍÊáØ + ÈåÑÌÙ æÍè åèÑÏ ÎÇÑÌêñ. ÊïæÔà ÇäåèÇÑÏ + èÊïÓÊÎÏå åæ âÈä ÏèÇä ÎÇÕÉ. + ÊåÙñæ áê <link linkend="resource">ÇäåäÍâ</link> + ääÍÕèä Ùäé äÇÆÍÉ äãÇáÉ çÐç + ÇäÏñèÇä èÇäÃæèÇÙ ÇäåèÑÏêñÉ ÇäåâÇÈäÉ. </para> <note> <simpara> - The resource type was introduced in PHP 4 + ÃïÏÎðä ÇäæèÙ ÇäåèÑÏêñ áê PHP 4 </simpara> </note> <sect2 id="language.types.resource.casting"> - <title>Converting to resource</title> + <title>ÇäÊñÍèêä Åäé åèÑÏ</title> <para> - As resource types hold special handlers to opened - files, database connections, image canvas areas and - the like, you cannot convert any value to a resource. + æØÑÇ äÃæñ ÇäÃæèÇÙ ÇäåèÑÏêñÉ ÊÍÊáØ ÈåâÇÈÖ ÎÇÕÉ æÍè ÇäåäáÇÊ + ÇäåáÊèÍɬ ÅÊÕÇäÇÊ ÇäâèÇÙÏ ÇäÈêÇæêñɬ åæÇ×â äèÍÉ ÕèÑêñÉ + èåÇ ÔÇÈç Ðä㬠áÅæñç äÇ êåãæã ÊÍèêä Ãêñ âêåÉ Åäé åèÑÏ. </para> </sect2> <sect2 id="language.types.resource.self-destruct"> - <title>Freeing resources</title> + <title>ÊÍÑêÑ ÇäåèÇÑÏ</title> <para> - Due to the reference-counting system introduced - with PHP4's Zend-engine, it is automatically detected - when a resource is no longer referred to (just - like Java). When this is - the case, all resources that were in use for this - resource are made free by the garbage collector. - For this reason, it is rarely ever necessary to - free the memory manually by using some free_result - function. + ÈáÖä æØÇå ÙÏñ ÇäåÑÇÌÙ ÇäÐê ÃïÏÎðä + åÙ åïÍÑñðã Zend-engine ÇäÎÇÕ ÈàPHP4¬ áÅæñç êÍÏË ãÔá Âäêñ + ÙæÏåÇ äÇ êÕÈÍ åèÑÏ åÇ åïÔÇÑÇë Åäêç åÑÌÙêÇë (åËäåÇ + ÇäÍÇä åÙ Java). ÙæÏåÇ Êãèæ çÐç çê + ÇäÃÍèÇä¬ áÅæñ ãÇáÉ ÇäåèÇÑÏ ÇäÊê ãÇæÊ âêÏ ÇäÅÓÊÎÏÇå åæ çÐÇ + ÇäåèÑÏ êï×äîâ ÓÑÇÍçÇ åæ âÈä ÌÇåÙ ÇäåïçòåîäÇÊ. + äçÐÇ ÇäÓñÈȬ áÅæñç ÍÊé åæ ÇäæñÇÏÑ Ãæ ÊÖ×Ñ + äÊÍÑêÑ ÇäÐÇãÑÉ êÏèêÇë ÈÇÓÊÎÏÇå ÏÇäÉ free_result + äÈÙÖ åÑÇÊ. <note> <simpara> - Persistent database links are special, they - are <emphasis>not</emphasis> destroyed by the - garbage collector. See also the section about <link linkend="features.persistent-connections">persistent - connections</link>. + ÊÊÓå ÑèÇÈ× ÇäâèÇÙÏ ÇäÈêÇæêñÉ ÇäåïÏÇèåÉ ÈãèæçÇ ÎÇÕÉ. + <emphasis>äÇ êÊå</emphasis> ÊÏåêÑçÇ åæ âÈä + ÌÇåÙ ÇäåïçòåîäÇÊ. ÊåÙñîæ ÇêÖÇ áê ÇäáÕä ÇäÎÇÕ Èà<link linkend="features.persistent-connections">ÇäÅÊÕÇäÇÊ + ÇäåïÏîÇèðåîÉ</link>. </simpara> </note> </para> @@ -1976,40 +1975,40 @@ <sect1 id="language.types.null"> <title>NULL</title> <para> - The special &null; value represents - that a variable has no value. &null; is the only possible value of type + ÊåËä âêåÉ &null; ÇäÎÇÕÉ + ÚêÇÈ èÌèÏ âêåÉ äÏé åïÊÚêñðÑ. &null; çê ÇäâêåÉ ÇäååãæÉ ÇäèÍêÏÉ ääæèÙ <type>NULL</type>. </para> <note> <simpara> - The null type was introduced in PHP 4 + ÃïÏÎðä æèÙ null åÙ PHP 4 </simpara> </note> <para> - A variable is considered to be &null; if + êÙÊÈÑ åÊÚêÑ åÇ Ùäé Ãæñç &null; ÅÐÇ <itemizedlist> <listitem> <para> - it has been assigned the constant &null;. + ÅÐÇ Ùïêñðæî äç ÇäËÇÈÊ &null;. </para> </listitem> <listitem> <para> - it has not been set to any value yet. + ÅÐÇ äå êïÍÏñîÏ äÃê âêåÉ ÈÙÏ. </para> </listitem> <listitem> <para> - it has been <function>unset</function>. + ÊåÊ <function>ÅÒÇäÉ ÊÙêêæç</function>. </para> </listitem> </itemizedlist> </para> <sect2 id="language.types.null.syntax"> - <title>Syntax</title> + <title>ÇäÕñêÚÉ</title> <para> - There is only one value of type &null;, and that is - the case-insensitive keyword &null;. + çæÇã áâ× âêåÉ èÇÍÏÉ åæ ÇäæñèÙ &null; èçê Êäã + ÇäãäåÉ ÇäåáÊÇÍêñÉ ÇäåÊÍÓÓÉ äÍÇäÉ ÇäÃÍÑá &null;. <informalexample> <programlisting role="php"><![CDATA[ <?php @@ -2019,87 +2018,87 @@ </informalexample> </para> <para> - See also <function>is_null</function> and <function>unset</function>. + ÊåÙñîæ ÃêÖÇ áê <function>is_null</function> è <function>unset</function>. </para> </sect2> </sect1> <sect1 id="language.pseudo-types"> - <title>Pseudo-types used in this documentation</title> + <title>ÃÔÈÇç-ÇäÃæèÇÙ ÇäåïÓòÊîÎòÏîåîÉ áê çÐç ÇäèËêâÉ</title> <sect2 id="language.types.mixed"> - <title>mixed</title> + <title>ååÒèÌ (mixed)</title> <para> - <literal>mixed</literal> indicates that a parameter may accept multiple (but not - necesseraly all) types. + êÔêÑ <literal>mixed</literal> Åäé Ãæñ åÙäåÉ åÇ êåãæçÇ âÈèä ÙÏÉ (äãæ äêÓ + ÈÇäÖÑèÑÉ ãäñ) ÃæèÇÙ. </para> <para> - <function>gettype</function> for example will accept all PHP types, - while <function>str_replace</function> will accept strings and arrays. + Ùäé ÓÈêä ÇäåËÇä¬ <function>gettype</function> ÓÊâÈä ãäñ ÃæèÇÙ PHP types + áê Íêæ Ãæñ <function>str_replace</function> ÓÊâÈä ÇäÓñäÇÓä ÇäæñÕêñÉ èÇäåÕáèáÇÊ. </para> </sect2> <sect2 id="language.types.number"> - <title>number</title> + <title>ÙÏÏ (number)</title> <para> - <literal>number</literal> indicates that a parameter can be either - <type>integer</type> or <type>float</type>. + êÔêÑ <literal>number</literal> Åäé Ãæñ åÙäåÉ åÇ êåãæ Ãæ Êãèæ + <type>ÙÏÏ ÕÍêÍ (integer)</type> Ãè <type>ÙÇÆå (float)</type>. </para> </sect2> <sect2 id="language.types.callback"> - <title>callback</title> + <title>ÊÐãêÑ (callback)</title> <para> - Some functions like <function>call_user_func</function> - or <function>usort</function> accept user defined - callback functions as a parameter. Callback functions can not only - be simple functions but also object methods including static class - methods. - </para> - <para> - A PHP function is simply passed by its name as a string. You can - pass any builtin or user defined function with the exception of - <function>array</function>, - <function>echo</function>, - <function>empty</function>, - <function>eval</function>, - <function>exit</function>, - <function>isset</function>, - <function>list</function>, - <function>print</function> and + ÈÙÖ ÇäÏñèÇä åËä <function>call_user_func</function> + Ãè <function>usort</function> ÊâÈä ÈÏèÇä ÇäÊÐãêÑ + ÇäåïÙÑñîáÉ åæ âÈä ÇäåÓÊÎÏå ãåîÙòäîåîÉ. äÇ êåãæ äÏèÇä ÇäÊñÐãêÑ Ãæ Êãèæ áâ× + åÌÑÏ ÏèÇä Èä ÃêÖÇ åæÇçÌ ãÇÆæêñÉ ÈåÇ áê Ðäã åæÇçÌ + ÇäÃÕæÇá ÇäÑñÇãÏÉ. + </para> + <para> + ÈÈÓÇ×ɬ êÊå ÊåÑêÑ ÏÇäÉ PHP åæ ÎäÇä ÅÓåçÇ Ùäé Ôãä ÓäÓäÉ æÕêñÉ. êåãæã + ÊåÑêÑ ÃêÉ ÏÇäÉ åïÊîÖñîåîæîÉ ÙæÏ ÇäÊñÔêêÏ Ãè åïÙîÑñîáîÉ åæ âÈä ÇäåÓÊÎÏå ÈÇÓÊËæÇÁ + <function>array</function>¬ + <function>echo</function>¬ + <function>empty</function>¬ + <function>eval</function>¬ + <function>exit</function>¬ + <function>isset</function>¬ + <function>list</function>¬ + <function>print</function> è <function>unset</function>. </para> <para> - A method of an instantiated object is passed as an array containing - an object as the element with index 0 and a method name as the - element with index 1. + êÊå ÊåÑêÑ åæçÌ ãÇÆæ Ðê åËêä ãåÕáèáÉ ÊÍÊèê + ãÇÆæÇë Ùäé Ôãä ÙæÕÑ áçÑÓç 0 èÅÓåî åæçÌ Ùäé Ôãä + ÙæÕÑ áçÑÓç 1. </para> <para> - Static class methods can also be passed without instantiating an - object of that class by passing the class name instead of an - object as the element with index 0. + êåãæ ÃêÖÇ ÊåÑêÑ äåæÇçÌ ÇäÃÕæÇá ÇäÑñÇãÏÉ åæ Ïèæ ÅæÔÇÁ åËêä + äãÇÆæ åæ çÐÇ ÇäÕñðæá åæ ÎäÇä ÊåÑêÑ ÅÓå ÇäÕñðæá ÈÏäÇ åæ ÊåÑêÑ + ãÇÆæ Ùäé Ãæñç ÙæÕÑ èáçÑÓç 0. </para> <para> <example> <title> - Callback function examples + ÃåËäÉ ÏÇäÉ ÊÐãêÑ (Callback function) </title> <programlisting role="php"><![CDATA[ <?php -// simple callback example +// åËÇä Ùæ ÊÐãêÑ ÈÓê× function my_callback_function() { - echo 'hello world!'; + echo 'ÃçäÇ êÇ ÙÇäå!'; } call_user_func('my_callback_function'); -// method callback examples +// ÃåËäÉ Ùæ ÊÐãêÑ åæçÌ (method callback) class MyClass { function myCallbackMethod() { - echo 'Hello World!'; + echo 'ÃçäÇ êÇ ÙÇäå!'; } } -// static class method call without instantiating an object +// åæÇÏÇÉ åæçÌ Õæá ÑÇãÏ åæ Ïèæ ÅæÔÇÁ åËêä äãÇÆæ call_user_func(array('MyClass', 'myCallbackMethod')); -// object method call +// åæÇÏÇÉ åæçÌ ãÇÆæêñ $obj = new MyClass(); call_user_func(array(&$obj, 'myCallbackMethod')); ?> @@ -2109,32 +2108,32 @@ </sect2> </sect1> <sect1 id="language.types.type-juggling"> - <title>Type Juggling</title> + <title>ÇäÊñäÇÙÈ ÈÇäÃæèÇÙ</title> <simpara> - PHP does not require (or support) explicit type definition in - variable declaration; a variable's type is determined by the - context in which that variable is used. That is to say, if you - assign a string value to variable <parameter>$var</parameter>, - <parameter>$var</parameter> becomes a string. If you then assign an - integer value to <parameter>$var</parameter>, it becomes an - integer. + äÇ ÊÔÊÑ× PHP (Ãè ÊÏÙå) ÊÙÑêáÇë ÕÑêÍÇë ääæèÙ áê + ÅÙäÇæ ÇäåïÊÚêñðÑ» êïÍÏñîÏ æèÙ ÇäåÊÚêñðÑ åæ âÈä + ÇäÓñðêÇâ ÇäÐê êïÓÊÎÏå áêç Ðäã ÇäåÊÚêñðÑ. çÐÇ äæâèä Ãæñç ÅÐÇ + ÙêñîæÊ âêåÉ ÓäÓäÉ æÕêñÉ Åäé ÇäåÊÚêñðÑ <parameter>$var</parameter>¬ + áÅæñ <parameter>$var</parameter> ÊÕÈÍ ÓäÓäÉ æÕêñÉ. ÍêæÆÐ¬ ÅÐÇ ÙêñîæÊ + âêåÉ ÙÏÏ ÕÍêÍ Åäé <parameter>$var</parameter>¬ áÅæñç êÕÈÍ + ÙÏÏÇë ÕÍêÍÇë. </simpara> <para> - An example of PHP's automatic type conversion is the addition - operator '+'. If any of the operands is a float, then all - operands are evaluated as floats, and the result will be a - float. Otherwise, the operands will be interpreted as integers, - and the result will also be an integer. Note that this does NOT - change the types of the operands themselves; the only change is in - how the operands are evaluated. + åËÇä Ùæ ÇäÊñÍèêä ÇäÂäêñ ääÃæèÇÙ êÊåËä áê ÅÖÇáÉ + åïÔîÚðä '+'. ÅÐÇ ãÇæ Ãê åæ ÇäåÙÇåäÇÊ ÙÈÇÑÉ Ùæ ÙÇÆå¬ ÍêæçÇ áÅæñ ãÇáÉ + ÇäåÙÇåäÇÊ ÓÊïâîêñîå Ùäé ÃæñçÇ ÙèÇÆå èÇäæñÊêÌÉ ÓÊãèæ + ÙÈÇÑÉ Ùæ ÙÇÆå. ÈÎäÇá Ðä㬠áÅæñ ÇäåÙÇåäÇÊ ÓÊïÊîÑÌîå Ùäé ÃæñçÇ ÃÙÏÇÏ ÕÍêÍÉ + èÇäæñÊêÌÉ ÓÊãèæ ÃêÖÇ ÙÏÏÇë ÕÍêÍÇë. ÅæÊÈç Åäé Ãæñ çÐÇ äÇ + êïÚîêñðÑ ÃæèÇÙ ÇäåÙÇåäÇÊ áê ÍÏ ÐÇÊçÇ» ÇäÊñÚêêÑ ÇäèÍêÏ êÍÏË + áê ×ÑêâÉ Êâêêå ÇäåÙÇåäÇÊ. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = "0"; // $foo is string (ASCII 48) -$foo += 2; // $foo is now an integer (2) -$foo = $foo + 1.3; // $foo is now a float (3.3) -$foo = 5 + "10 Little Piggies"; // $foo is integer (15) -$foo = 5 + "10 Small Pigs"; // $foo is integer (15) +$foo = "0"; // $foo çê ÓäÓäÉ æÕêñÉ (ASCII 48) +$foo += 2; // $foo çê ÇäÂæ ÙÏÏ ÕÍêÍ (2) +$foo = $foo + 1.3; // $foo çê ÇäÂæ ÙÇÆå (3.3) +$foo = 5 + "10 ÃÍÕæÉ ÕÚêÑÉ"; // $foo çê ÙÏÏ ÕÍêÍ (15) +$foo = 5 + "10 ÌåÇä ÕÚêÑÉ"; // $foo çê ÙÏÏ ÕÍêÍ (15) ?> ]]><!-- bad example, no real operator (must be used with variable, modifies it too) $foo++; // $foo is the string "1" (ASCII 49) @@ -2159,101 +2158,101 @@ </informalexample> </para> <simpara> - If the last two examples above seem odd, see <link linkend="language.types.string.conversion">String - conversion to numbers</link>. + ÅÐÇ ØçÑ ÇäåËÇäêæ ÇäÐêæ ÈÇäÃÙäé ÚÑêÈêæ¬ áÊåîÙñîæ áê <link linkend="language.types.string.conversion">ÊÍèêä ÓäÓäÉ æÕêñÉ + Åäé ÃÙÏÇÏ</link>. </simpara> <simpara> - If you wish to force a variable to be evaluated as a certain type, - see the section on <link linkend="language.types.typecasting">Type - casting</link>. If you wish to change the type of a variable, see + ÅÐÇ ÑÚÈÊ áê ÅÌÈÇÑ åÊÚêÑ Ùäé Ãæ êïâîêñîå Ùäé Ãæñç åæ æèÙ ÎÇÕ¬ + áÊåîÙñîæ áê ÇäáÕä ÇäåÊÙäâ Èà <link linkend="language.types.typecasting">ÇäÊñÍèêä ÇäâÓÑêñ + ääÃæèÇÙ</link>. ÅÐÇ ÑÚÈÊ áê ÊÚêêÑ æèÙ åÊÚêñðѬ áÊåÙñîæ áê <function>settype</function>. </simpara> <para> - If you would like to test any of the examples in this section, you - can use the <function>var_dump</function> function. + ÅÐÇ ãæÊ ÊÑÚÈ áê ÇÎÊÈÇÑ Ãê åæ ÇäÃåËäÉ ÇäÊê ÈçÐÇ ÇäáÕä¬ áÈÅåãÇæã + ÇÓÊÎÏÇå ÏÇäÉ <function>var_dump</function>. </para> <note> <para> - The behaviour of an automatic conversion to array is currently - undefined. + áê ÇäèâÊ ÇäÍÇÖѬ êÊÓå Óäèãï ÊÍèêäí Âäêñ Åäé åÕáèáÉ ÈÃæñç + ÚêÑ åïÙîÑñîá. </para> <para> <informalexample> <programlisting role="php"><![CDATA[ <?php -$a = "1"; // $a is a string -$a[0] = "f"; // What about string offsets? What happens? +$a = "1"; // $a çè ÓäÓäÉ æÕêñÉ +$a[0] = "f"; // åÇÐÇ Ùæ ÅÒÇÍÇÊ ÇäÓñäÇÓä ÇäæñÕêñÉ¿ åÐÇ ÌÑé¿ ?> ]]></programlisting> </informalexample> </para> <para> - Since PHP (for historical reasons) supports indexing into strings - via offsets using the same syntax as array indexing, the example - above leads to a problem: should $a become an array with its first - element being "f", or should "f" become the first character of the - string $a? + åæÐ Ãæ ÃÕÈÍÊ PHP (äÃÓÈÇÈ ÊÇÑêÎêñÉ) ÊÏÙå ÇäáçÑÓÉ Öåæ ÇäÓñäÇÓä ÇäæñÕêñÉ + ÙêÑ ÇäÅÒÇÍÇÊ èÈÇÓÊÎÏÇå æáÓ ÕêÚÉ áçÑÓÉ ÇäåÕáèáÇʬ áÅæñ ÇäåËÇä + ÇäÐê ÈÇäÃÙäé êÊÓÈÈ áê åÔãäÉ: çä êÌÈ Ùäé $a Ãæ êÕÈÍ åÕáèáÉ èêãèæ ÙæÕÑç + ÇäÃèä "f" Ãè êÌÈ Ùäé "f" Ãæ êÕÈÍ ÇäÍÑá ÇäÃèä ÇäÎÇÕ + ÈÇäÓñðäÓäÉ ÇäæñîÕêñÉ $a¿ </para> <para> - The current versions of PHP interpret the second assignment as - a string offset identification, so $a becomes "f", the result - of this automatic conversion however should be considered - undefined. PHP 4 introduced the new curly bracket syntax to access - characters in string, use this syntax instead of the one presented - above: + ÇäÅÕÏÇÑÇÊ ÇäÍÇäêñÉ åæ PHP ÊÊÑÌå ÇäÊÙêêæ ÇäËÇæê Ùäé Ãæñç + ÊÔÎêÕ äÅÒÇÍÉ ÓäÓäÉ æÕêñÉ ÈÍêË Ãæñ $a ÊÕÈÍ "f" èæÊêÌÉ + çÐÇ ÇäÊñÍèêä ÇäÂäêñ êÌÈ åÙ Ðäã Ãæ êÙÊÈÑ + Ùäé Ãæñç ÚêÑ åïÙîÑñîá. ÃÏÎäÊ PHP 4 ÕêÚÉ ÇäÍÇÖæÉ ÇäåÙâèáÉ ÈÚÑÖ èäèÌ + ÍÑèá ÓäÓäÉ æÕêñɬ ÇÓÊÎÏå çÐç ÇäÕñðêÚÉ ÈÏäÇ åæ Êäã ÇäåïâîÏîåÉ + áê ÇäÃÙäé: <informalexample> <programlisting role="php"><![CDATA[ <?php -$a = "abc"; // $a is a string -$a{1} = "f"; // $a is now "afc" +$a = "abc"; // $a çè ÓäÓäÉ æÕêñÉ +$a{1} = "f"; // $a çè ÇäÂæ "afc" ?> ]]></programlisting> </informalexample> - See the section titled <link linkend="language.types.string.substr">String - access by character</link> for more informaton. + ÊåîÙñîæ áê ÇäáÕä ÇäåÙæèæ <link linkend="language.types.string.substr">èäèÌ ÓäÓäÉ æÕêñÉ + åæ ÎäÇä ÍÑá</link> èÐäã åæ ÃÌä ÇäÍÕèä Ùäé åÒêÏ åæ ÇäåÙäèåÇÊ. </para> </note> <sect2 id="language.types.typecasting"> - <title>Type Casting</title> + <title>ÇäÊñîÍèêä ÇäâÓÑêñ ääÃæèÇÙ</title> <para> - Type casting in PHP works much as it does in C: the name of the - desired type is written in parentheses before the variable which - is to be cast. + êÙåä ÇäÊñîÍèêä ÇäâÓÑêñ äÏé PHP Ùäé æáÓ åæèÇä C: êïãÊÈï ÅÓå + ÇäæñîèÙ ÇäåÑÚèÈ áêç Öåæ âèÓêæ âÈä ÇäåÊÚêñðÑ ÇäÐê + êÊèÌÈ ÊÍèêäç âÓÑêÇë. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = 10; // $foo is an integer -$bar = (boolean) $foo; // $bar is a boolean +$foo = 10; // $foo çè ÙÏÏ ÕÍêÍ +$bar = (boolean) $foo; // $bar çè åæ×âê ?> ]]></programlisting> </informalexample> </para> <para> - The casts allowed are: + ÇäÊñîÍèêäÇÊ ÇäâÓÑêñÉ ÇäåÓåèÍ ÈçÇ çê: <itemizedlist> <listitem> - <simpara>(int), (integer) - cast to integer</simpara> + <simpara>(int)¬ (integer) - ääÊÍèêä âÓÑêÇ Åäé ÙÏÏ ÕÍêÍ</simpara> </listitem> <listitem> - <simpara>(bool), (boolean) - cast to boolean</simpara> + <simpara>(bool)¬ (boolean) - ääÊÍèêä âÓÑêÇ Åäé åæ×âê</simpara> </listitem> <listitem> - <simpara>(float), (double), (real) - cast to float</simpara> + <simpara>(float)¬ (double)¬ (real) - ääÊÍèêä âÓÑêÇ Åäé ÙÇÆå</simpara> </listitem> <listitem> - <simpara>(string) - cast to string</simpara> + <simpara>(string) - ääÊÍèêä âÓÑêÇ Åäé ÓäÓäÉ æÕêñÉ</simpara> </listitem> <listitem> - <simpara>(array) - cast to array</simpara> + <simpara>(array) - ääÊÍèêä âÓÑêÇ Åäé åÕáèáÉ</simpara> </listitem> <listitem> - <simpara>(object) - cast to object</simpara> + <simpara>(object) - ääÊÍèêä âÓÑêÇ Åäé ãÇÆæ</simpara> </listitem> </itemizedlist> </para> <para> - Note that tabs and spaces are allowed inside the parentheses, so - the following are functionally equivalent: + äÇÍØ Ãæñç êÓåÍ ÈÇäÌÏèäÇÊ èÇäåÓÇáÇÊ ÏÇÎä ÇäÃâèÇ ÈÍêË Ãæ + åÇ êäê êÊÔÇÈç ÙåäêÇë: <informalexample> <programlisting role="php"><![CDATA[ <?php @@ -2265,18 +2264,18 @@ </para> <note> <para> - Instead of casting a variable to string, you can also enclose - the variable in double quotes. + ÈÏäÇ åæ ÇäÊñîÍèêä ÇäâÓÑêñ äåÊÚêñðÑ Åäé ÓäÓäÉ æÕêñɬ êåãæã ÃêÖÇ ÊÖåêæ + ÇäåÊÚêñí ÏÇÎä ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = 10; // $foo is an integer -$str = "$foo"; // $str is a string -$fst = (string) $foo; // $fst is also a string +$foo = 10; // $foo çè ÙÏÏ ÕÍêÍ +$str = "$foo"; // $str çè ÓäÓäÉ æÕêñÉ +$fst = (string) $foo; // $fst çè ÃêÖÇ ÓäÓäÉ æÕêñÉ -// This prints out that "they are the same" +// ê×ÈÙ çÐÇ ÇäÊñÇäê "ÅæñçÇ åÊÔÇÈçÉ" if ($fst === $str) { - echo "they are the same"; + echo "ÅæñçÇ åÊÔÇÈçÉ"; } ?> ]]></programlisting> @@ -2284,61 +2283,61 @@ </para> </note> <para> - It may not be obvious exactly what will happen when casting - between certain types. For more info, see these sections: + êåãæ ÃäÇ êãèæ ÇäÃåÑ èÇÖÍÇ Ùäé èÌç Ïâêâ ÈÎÕèÕ åÇ ÇäÐê ÓêÍÏË ÙæÏ ÇäÊñîÍèêä ÇäâÓÑêñ + Èêæ ÈÙÖ ÇäÃæèÇÙ. äåÒêÏ åæ ÇäåÙäèåÇʬ ÊåîÙñîæ áê çÐç ÇäáÕèä: <itemizedlist> <listitem> <simpara> - <link linkend="language.types.boolean.casting">Converting to - boolean</link> + <link linkend="language.types.boolean.casting">ÇäÊñÍèêä Åäé + åæ×âê</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.integer.casting">Converting to - integer</link> + <link linkend="language.types.integer.casting">ÇäÊñÍèêä Åäé + ÙÏÏ ÕÍêÍ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.float.casting">Converting to - float</link> + <link linkend="language.types.float.casting">ÇäÊñÍèêä Åäé + ÙÇÆå</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.casting">Converting to - string</link> + <link linkend="language.types.string.casting">ÇäÊñÍèêä Åäé + ÓäÓäÉ æÕêñÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.array.casting">Converting to - array</link> + <link linkend="language.types.array.casting">ÇäÊñÍèêä Åäé + åÕáèáÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.object.casting">Converting to - object</link> + <link linkend="language.types.object.casting">ÇäÊñÍèêä Åäé + ãÇÆæ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.resource.casting">Converting to - resource</link> + <link linkend="language.types.resource.casting">ÇäÊñÍèêä Åäé + åèÑÏ</link> </simpara> </listitem> <!-- don't exist yet <listitem> - <simpara><link linkend="language.types.null.casting">Converting to + <simpara><link linkend="language.types.null.casting">ÇäÊñÍèêä Åäé &null;</link></simpara> </listitem> --> <listitem> <simpara> - <link linkend="types.comparisons">The type comparison tables</link> + <link linkend="types.comparisons">ÌÏÇèä åâÇÑæÉ ÇäÃæèÇÙ</link> </simpara> </listitem> </itemizedlist>
Index: phpdoc-ar/language/types.xml diff -u phpdoc-ar/language/types.xml:1.7 phpdoc-ar/language/types.xml:1.8 --- phpdoc-ar/language/types.xml:1.7 Sat Sep 20 01:58:49 2003 +++ phpdoc-ar/language/types.xml Sun Sep 21 23:46:33 2003 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-6"?> -<!-- $Revision: 1.7 $ --> -<!-- EN-Revision: 1.123 Maintainer: hafid Status: working --> +<!-- $Revision: 1.8 $ --> +<!-- EN-Revision: 1.123 Maintainer: hafid Status: ready --> <chapter id="language.types"> <title>ÇäÃæèÇÙ</title> <sect1 id="language.types.intro"> @@ -145,7 +145,6 @@ ÈÇÙÊÈÇÑ ÃæçÇ ÊØçÑ ÃåËäÉ äåâÇÑæÇÊ åÊÙäâÉ ÈÃæèÇÙ åÊÙÏÏÉ. </simpara> </sect1> - <sect1 id="language.types.boolean"> <title>Booleans - Çäåæ×âêÇÊ</title> <simpara> @@ -1910,17 +1909,17 @@ <sect2 id="language.types.object.casting"> <title>ÇäÊñÍèêä Åäé ãÇÆæ</title> <para> - If an object is converted to an object, it is not modified. If a value - of any other type is converted to an object, a new instance of the - <literal>stdClass</literal> built in class is created. If the value - was null, the new instance will be empty. For any other value, a - member variable named <literal>scalar</literal> will contain the - value. + ÅÐÇ Íïèñðä ãÇÆæ åÇ Åäé ãÇÆæ ÂÎѬ áÅæñç äÇ êïÙÏñîä. ÅÐÇ ÍïèñðäÊ âêåÉ + Ãê æèÙ ÂÎÑ Åäé ãÇÆæ¬ áÅæñç êÊå ÅæÔÇÁ åËêäí ÌÏêÏ + äÕæá <literal>stdClass</literal> ÇäåïÊÖñîåæ ÙæÏ ÇäÊñÔêêÏ. ÅÐÇ ãÇæÊ ÇäâêåÉ + null¬ áÅæñ ÇäåËêä ÇäÌÏêÏ Óêãèæ áÇÑÚÇë. ÈÇäæñÓÈÉ äÃêñ âêåÉ ÃÎÑé¬ áÅæñ + åïÊîÚîêñðÑ ÙÖèêñ êïÏòÙîé <literal>scalar</literal> ÓêÊÖåæ + ÇäâêåÉ. <informalexample> <programlisting role="php"><![CDATA[ <?php $obj = (object) 'ciao'; -echo $obj->scalar; // outputs 'ciao' +echo $obj->scalar; // êïÎÑÌ 'ciao' ?> ]]></programlisting> </informalexample> @@ -1928,46 +1927,46 @@ </sect2> </sect1> <sect1 id="language.types.resource"> - <title>Resource</title> + <title>ÇäåèÑÏ</title> <para> - A resource is a special variable, holding - a reference to an external resource. Resources - are created and used by special functions. - See the <link linkend="resource">appendix</link> - for a listing of all these - functions and the corresponding resource types. + ÇäåèÑÏ çè åïÊîÚîêñðÑ ÎÇÕ êÍÊáØ + ÈåÑÌÙ æÍè åèÑÏ ÎÇÑÌêñ. ÊïæÔà ÇäåèÇÑÏ + èÊïÓÊÎÏå åæ âÈä ÏèÇä ÎÇÕÉ. + ÊåÙñæ áê <link linkend="resource">ÇäåäÍâ</link> + ääÍÕèä Ùäé äÇÆÍÉ äãÇáÉ çÐç + ÇäÏñèÇä èÇäÃæèÇÙ ÇäåèÑÏêñÉ ÇäåâÇÈäÉ. </para> <note> <simpara> - The resource type was introduced in PHP 4 + ÃïÏÎðä ÇäæèÙ ÇäåèÑÏêñ áê PHP 4 </simpara> </note> <sect2 id="language.types.resource.casting"> - <title>Converting to resource</title> + <title>ÇäÊñÍèêä Åäé åèÑÏ</title> <para> - As resource types hold special handlers to opened - files, database connections, image canvas areas and - the like, you cannot convert any value to a resource. + æØÑÇ äÃæñ ÇäÃæèÇÙ ÇäåèÑÏêñÉ ÊÍÊáØ ÈåâÇÈÖ ÎÇÕÉ æÍè ÇäåäáÇÊ + ÇäåáÊèÍɬ ÅÊÕÇäÇÊ ÇäâèÇÙÏ ÇäÈêÇæêñɬ åæÇ×â äèÍÉ ÕèÑêñÉ + èåÇ ÔÇÈç Ðä㬠áÅæñç äÇ êåãæã ÊÍèêä Ãêñ âêåÉ Åäé åèÑÏ. </para> </sect2> <sect2 id="language.types.resource.self-destruct"> - <title>Freeing resources</title> + <title>ÊÍÑêÑ ÇäåèÇÑÏ</title> <para> - Due to the reference-counting system introduced - with PHP4's Zend-engine, it is automatically detected - when a resource is no longer referred to (just - like Java). When this is - the case, all resources that were in use for this - resource are made free by the garbage collector. - For this reason, it is rarely ever necessary to - free the memory manually by using some free_result - function. + ÈáÖä æØÇå ÙÏñ ÇäåÑÇÌÙ ÇäÐê ÃïÏÎðä + åÙ åïÍÑñðã Zend-engine ÇäÎÇÕ ÈàPHP4¬ áÅæñç êÍÏË ãÔá Âäêñ + ÙæÏåÇ äÇ êÕÈÍ åèÑÏ åÇ åïÔÇÑÇë Åäêç åÑÌÙêÇë (åËäåÇ + ÇäÍÇä åÙ Java). ÙæÏåÇ Êãèæ çÐç çê + ÇäÃÍèÇä¬ áÅæñ ãÇáÉ ÇäåèÇÑÏ ÇäÊê ãÇæÊ âêÏ ÇäÅÓÊÎÏÇå åæ çÐÇ + ÇäåèÑÏ êï×äîâ ÓÑÇÍçÇ åæ âÈä ÌÇåÙ ÇäåïçòåîäÇÊ. + äçÐÇ ÇäÓñÈȬ áÅæñç ÍÊé åæ ÇäæñÇÏÑ Ãæ ÊÖ×Ñ + äÊÍÑêÑ ÇäÐÇãÑÉ êÏèêÇë ÈÇÓÊÎÏÇå ÏÇäÉ free_result + äÈÙÖ åÑÇÊ. <note> <simpara> - Persistent database links are special, they - are <emphasis>not</emphasis> destroyed by the - garbage collector. See also the section about <link linkend="features.persistent-connections">persistent - connections</link>. + ÊÊÓå ÑèÇÈ× ÇäâèÇÙÏ ÇäÈêÇæêñÉ ÇäåïÏÇèåÉ ÈãèæçÇ ÎÇÕÉ. + <emphasis>äÇ êÊå</emphasis> ÊÏåêÑçÇ åæ âÈä + ÌÇåÙ ÇäåïçòåîäÇÊ. ÊåÙñîæ ÇêÖÇ áê ÇäáÕä ÇäÎÇÕ Èà<link linkend="features.persistent-connections">ÇäÅÊÕÇäÇÊ + ÇäåïÏîÇèðåîÉ</link>. </simpara> </note> </para> @@ -1976,40 +1975,40 @@ <sect1 id="language.types.null"> <title>NULL</title> <para> - The special &null; value represents - that a variable has no value. &null; is the only possible value of type + ÊåËä âêåÉ &null; ÇäÎÇÕÉ + ÚêÇÈ èÌèÏ âêåÉ äÏé åïÊÚêñðÑ. &null; çê ÇäâêåÉ ÇäååãæÉ ÇäèÍêÏÉ ääæèÙ <type>NULL</type>. </para> <note> <simpara> - The null type was introduced in PHP 4 + ÃïÏÎðä æèÙ null åÙ PHP 4 </simpara> </note> <para> - A variable is considered to be &null; if + êÙÊÈÑ åÊÚêÑ åÇ Ùäé Ãæñç &null; ÅÐÇ <itemizedlist> <listitem> <para> - it has been assigned the constant &null;. + ÅÐÇ Ùïêñðæî äç ÇäËÇÈÊ &null;. </para> </listitem> <listitem> <para> - it has not been set to any value yet. + ÅÐÇ äå êïÍÏñîÏ äÃê âêåÉ ÈÙÏ. </para> </listitem> <listitem> <para> - it has been <function>unset</function>. + ÊåÊ <function>ÅÒÇäÉ ÊÙêêæç</function>. </para> </listitem> </itemizedlist> </para> <sect2 id="language.types.null.syntax"> - <title>Syntax</title> + <title>ÇäÕñêÚÉ</title> <para> - There is only one value of type &null;, and that is - the case-insensitive keyword &null;. + çæÇã áâ× âêåÉ èÇÍÏÉ åæ ÇäæñèÙ &null; èçê Êäã + ÇäãäåÉ ÇäåáÊÇÍêñÉ ÇäåÊÍÓÓÉ äÍÇäÉ ÇäÃÍÑá &null;. <informalexample> <programlisting role="php"><![CDATA[ <?php @@ -2019,87 +2018,87 @@ </informalexample> </para> <para> - See also <function>is_null</function> and <function>unset</function>. + ÊåÙñîæ ÃêÖÇ áê <function>is_null</function> è <function>unset</function>. </para> </sect2> </sect1> <sect1 id="language.pseudo-types"> - <title>Pseudo-types used in this documentation</title> + <title>ÃÔÈÇç-ÇäÃæèÇÙ ÇäåïÓòÊîÎòÏîåîÉ áê çÐç ÇäèËêâÉ</title> <sect2 id="language.types.mixed"> - <title>mixed</title> + <title>ååÒèÌ (mixed)</title> <para> - <literal>mixed</literal> indicates that a parameter may accept multiple (but not - necesseraly all) types. + êÔêÑ <literal>mixed</literal> Åäé Ãæñ åÙäåÉ åÇ êåãæçÇ âÈèä ÙÏÉ (äãæ äêÓ + ÈÇäÖÑèÑÉ ãäñ) ÃæèÇÙ. </para> <para> - <function>gettype</function> for example will accept all PHP types, - while <function>str_replace</function> will accept strings and arrays. + Ùäé ÓÈêä ÇäåËÇä¬ <function>gettype</function> ÓÊâÈä ãäñ ÃæèÇÙ PHP types + áê Íêæ Ãæñ <function>str_replace</function> ÓÊâÈä ÇäÓñäÇÓä ÇäæñÕêñÉ èÇäåÕáèáÇÊ. </para> </sect2> <sect2 id="language.types.number"> - <title>number</title> + <title>ÙÏÏ (number)</title> <para> - <literal>number</literal> indicates that a parameter can be either - <type>integer</type> or <type>float</type>. + êÔêÑ <literal>number</literal> Åäé Ãæñ åÙäåÉ åÇ êåãæ Ãæ Êãèæ + <type>ÙÏÏ ÕÍêÍ (integer)</type> Ãè <type>ÙÇÆå (float)</type>. </para> </sect2> <sect2 id="language.types.callback"> - <title>callback</title> + <title>ÊÐãêÑ (callback)</title> <para> - Some functions like <function>call_user_func</function> - or <function>usort</function> accept user defined - callback functions as a parameter. Callback functions can not only - be simple functions but also object methods including static class - methods. - </para> - <para> - A PHP function is simply passed by its name as a string. You can - pass any builtin or user defined function with the exception of - <function>array</function>, - <function>echo</function>, - <function>empty</function>, - <function>eval</function>, - <function>exit</function>, - <function>isset</function>, - <function>list</function>, - <function>print</function> and + ÈÙÖ ÇäÏñèÇä åËä <function>call_user_func</function> + Ãè <function>usort</function> ÊâÈä ÈÏèÇä ÇäÊÐãêÑ + ÇäåïÙÑñîáÉ åæ âÈä ÇäåÓÊÎÏå ãåîÙòäîåîÉ. äÇ êåãæ äÏèÇä ÇäÊñÐãêÑ Ãæ Êãèæ áâ× + åÌÑÏ ÏèÇä Èä ÃêÖÇ åæÇçÌ ãÇÆæêñÉ ÈåÇ áê Ðäã åæÇçÌ + ÇäÃÕæÇá ÇäÑñÇãÏÉ. + </para> + <para> + ÈÈÓÇ×ɬ êÊå ÊåÑêÑ ÏÇäÉ PHP åæ ÎäÇä ÅÓåçÇ Ùäé Ôãä ÓäÓäÉ æÕêñÉ. êåãæã + ÊåÑêÑ ÃêÉ ÏÇäÉ åïÊîÖñîåîæîÉ ÙæÏ ÇäÊñÔêêÏ Ãè åïÙîÑñîáîÉ åæ âÈä ÇäåÓÊÎÏå ÈÇÓÊËæÇÁ + <function>array</function>¬ + <function>echo</function>¬ + <function>empty</function>¬ + <function>eval</function>¬ + <function>exit</function>¬ + <function>isset</function>¬ + <function>list</function>¬ + <function>print</function> è <function>unset</function>. </para> <para> - A method of an instantiated object is passed as an array containing - an object as the element with index 0 and a method name as the - element with index 1. + êÊå ÊåÑêÑ åæçÌ ãÇÆæ Ðê åËêä ãåÕáèáÉ ÊÍÊèê + ãÇÆæÇë Ùäé Ôãä ÙæÕÑ áçÑÓç 0 èÅÓåî åæçÌ Ùäé Ôãä + ÙæÕÑ áçÑÓç 1. </para> <para> - Static class methods can also be passed without instantiating an - object of that class by passing the class name instead of an - object as the element with index 0. + êåãæ ÃêÖÇ ÊåÑêÑ äåæÇçÌ ÇäÃÕæÇá ÇäÑñÇãÏÉ åæ Ïèæ ÅæÔÇÁ åËêä + äãÇÆæ åæ çÐÇ ÇäÕñðæá åæ ÎäÇä ÊåÑêÑ ÅÓå ÇäÕñðæá ÈÏäÇ åæ ÊåÑêÑ + ãÇÆæ Ùäé Ãæñç ÙæÕÑ èáçÑÓç 0. </para> <para> <example> <title> - Callback function examples + ÃåËäÉ ÏÇäÉ ÊÐãêÑ (Callback function) </title> <programlisting role="php"><![CDATA[ <?php -// simple callback example +// åËÇä Ùæ ÊÐãêÑ ÈÓê× function my_callback_function() { - echo 'hello world!'; + echo 'ÃçäÇ êÇ ÙÇäå!'; } call_user_func('my_callback_function'); -// method callback examples +// ÃåËäÉ Ùæ ÊÐãêÑ åæçÌ (method callback) class MyClass { function myCallbackMethod() { - echo 'Hello World!'; + echo 'ÃçäÇ êÇ ÙÇäå!'; } } -// static class method call without instantiating an object +// åæÇÏÇÉ åæçÌ Õæá ÑÇãÏ åæ Ïèæ ÅæÔÇÁ åËêä äãÇÆæ call_user_func(array('MyClass', 'myCallbackMethod')); -// object method call +// åæÇÏÇÉ åæçÌ ãÇÆæêñ $obj = new MyClass(); call_user_func(array(&$obj, 'myCallbackMethod')); ?> @@ -2109,32 +2108,32 @@ </sect2> </sect1> <sect1 id="language.types.type-juggling"> - <title>Type Juggling</title> + <title>ÇäÊñäÇÙÈ ÈÇäÃæèÇÙ</title> <simpara> - PHP does not require (or support) explicit type definition in - variable declaration; a variable's type is determined by the - context in which that variable is used. That is to say, if you - assign a string value to variable <parameter>$var</parameter>, - <parameter>$var</parameter> becomes a string. If you then assign an - integer value to <parameter>$var</parameter>, it becomes an - integer. + äÇ ÊÔÊÑ× PHP (Ãè ÊÏÙå) ÊÙÑêáÇë ÕÑêÍÇë ääæèÙ áê + ÅÙäÇæ ÇäåïÊÚêñðÑ» êïÍÏñîÏ æèÙ ÇäåÊÚêñðÑ åæ âÈä + ÇäÓñðêÇâ ÇäÐê êïÓÊÎÏå áêç Ðäã ÇäåÊÚêñðÑ. çÐÇ äæâèä Ãæñç ÅÐÇ + ÙêñîæÊ âêåÉ ÓäÓäÉ æÕêñÉ Åäé ÇäåÊÚêñðÑ <parameter>$var</parameter>¬ + áÅæñ <parameter>$var</parameter> ÊÕÈÍ ÓäÓäÉ æÕêñÉ. ÍêæÆÐ¬ ÅÐÇ ÙêñîæÊ + âêåÉ ÙÏÏ ÕÍêÍ Åäé <parameter>$var</parameter>¬ áÅæñç êÕÈÍ + ÙÏÏÇë ÕÍêÍÇë. </simpara> <para> - An example of PHP's automatic type conversion is the addition - operator '+'. If any of the operands is a float, then all - operands are evaluated as floats, and the result will be a - float. Otherwise, the operands will be interpreted as integers, - and the result will also be an integer. Note that this does NOT - change the types of the operands themselves; the only change is in - how the operands are evaluated. + åËÇä Ùæ ÇäÊñÍèêä ÇäÂäêñ ääÃæèÇÙ êÊåËä áê ÅÖÇáÉ + åïÔîÚðä '+'. ÅÐÇ ãÇæ Ãê åæ ÇäåÙÇåäÇÊ ÙÈÇÑÉ Ùæ ÙÇÆå¬ ÍêæçÇ áÅæñ ãÇáÉ + ÇäåÙÇåäÇÊ ÓÊïâîêñîå Ùäé ÃæñçÇ ÙèÇÆå èÇäæñÊêÌÉ ÓÊãèæ + ÙÈÇÑÉ Ùæ ÙÇÆå. ÈÎäÇá Ðä㬠áÅæñ ÇäåÙÇåäÇÊ ÓÊïÊîÑÌîå Ùäé ÃæñçÇ ÃÙÏÇÏ ÕÍêÍÉ + èÇäæñÊêÌÉ ÓÊãèæ ÃêÖÇ ÙÏÏÇë ÕÍêÍÇë. ÅæÊÈç Åäé Ãæñ çÐÇ äÇ + êïÚîêñðÑ ÃæèÇÙ ÇäåÙÇåäÇÊ áê ÍÏ ÐÇÊçÇ» ÇäÊñÚêêÑ ÇäèÍêÏ êÍÏË + áê ×ÑêâÉ Êâêêå ÇäåÙÇåäÇÊ. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = "0"; // $foo is string (ASCII 48) -$foo += 2; // $foo is now an integer (2) -$foo = $foo + 1.3; // $foo is now a float (3.3) -$foo = 5 + "10 Little Piggies"; // $foo is integer (15) -$foo = 5 + "10 Small Pigs"; // $foo is integer (15) +$foo = "0"; // $foo çê ÓäÓäÉ æÕêñÉ (ASCII 48) +$foo += 2; // $foo çê ÇäÂæ ÙÏÏ ÕÍêÍ (2) +$foo = $foo + 1.3; // $foo çê ÇäÂæ ÙÇÆå (3.3) +$foo = 5 + "10 ÃÍÕæÉ ÕÚêÑÉ"; // $foo çê ÙÏÏ ÕÍêÍ (15) +$foo = 5 + "10 ÌåÇä ÕÚêÑÉ"; // $foo çê ÙÏÏ ÕÍêÍ (15) ?> ]]><!-- bad example, no real operator (must be used with variable, modifies it too) $foo++; // $foo is the string "1" (ASCII 49) @@ -2159,101 +2158,101 @@ </informalexample> </para> <simpara> - If the last two examples above seem odd, see <link linkend="language.types.string.conversion">String - conversion to numbers</link>. + ÅÐÇ ØçÑ ÇäåËÇäêæ ÇäÐêæ ÈÇäÃÙäé ÚÑêÈêæ¬ áÊåîÙñîæ áê <link linkend="language.types.string.conversion">ÊÍèêä ÓäÓäÉ æÕêñÉ + Åäé ÃÙÏÇÏ</link>. </simpara> <simpara> - If you wish to force a variable to be evaluated as a certain type, - see the section on <link linkend="language.types.typecasting">Type - casting</link>. If you wish to change the type of a variable, see + ÅÐÇ ÑÚÈÊ áê ÅÌÈÇÑ åÊÚêÑ Ùäé Ãæ êïâîêñîå Ùäé Ãæñç åæ æèÙ ÎÇÕ¬ + áÊåîÙñîæ áê ÇäáÕä ÇäåÊÙäâ Èà <link linkend="language.types.typecasting">ÇäÊñÍèêä ÇäâÓÑêñ + ääÃæèÇÙ</link>. ÅÐÇ ÑÚÈÊ áê ÊÚêêÑ æèÙ åÊÚêñðѬ áÊåÙñîæ áê <function>settype</function>. </simpara> <para> - If you would like to test any of the examples in this section, you - can use the <function>var_dump</function> function. + ÅÐÇ ãæÊ ÊÑÚÈ áê ÇÎÊÈÇÑ Ãê åæ ÇäÃåËäÉ ÇäÊê ÈçÐÇ ÇäáÕä¬ áÈÅåãÇæã + ÇÓÊÎÏÇå ÏÇäÉ <function>var_dump</function>. </para> <note> <para> - The behaviour of an automatic conversion to array is currently - undefined. + áê ÇäèâÊ ÇäÍÇÖѬ êÊÓå Óäèãï ÊÍèêäí Âäêñ Åäé åÕáèáÉ ÈÃæñç + ÚêÑ åïÙîÑñîá. </para> <para> <informalexample> <programlisting role="php"><![CDATA[ <?php -$a = "1"; // $a is a string -$a[0] = "f"; // What about string offsets? What happens? +$a = "1"; // $a çè ÓäÓäÉ æÕêñÉ +$a[0] = "f"; // åÇÐÇ Ùæ ÅÒÇÍÇÊ ÇäÓñäÇÓä ÇäæñÕêñÉ¿ åÐÇ ÌÑé¿ ?> ]]></programlisting> </informalexample> </para> <para> - Since PHP (for historical reasons) supports indexing into strings - via offsets using the same syntax as array indexing, the example - above leads to a problem: should $a become an array with its first - element being "f", or should "f" become the first character of the - string $a? + åæÐ Ãæ ÃÕÈÍÊ PHP (äÃÓÈÇÈ ÊÇÑêÎêñÉ) ÊÏÙå ÇäáçÑÓÉ Öåæ ÇäÓñäÇÓä ÇäæñÕêñÉ + ÙêÑ ÇäÅÒÇÍÇÊ èÈÇÓÊÎÏÇå æáÓ ÕêÚÉ áçÑÓÉ ÇäåÕáèáÇʬ áÅæñ ÇäåËÇä + ÇäÐê ÈÇäÃÙäé êÊÓÈÈ áê åÔãäÉ: çä êÌÈ Ùäé $a Ãæ êÕÈÍ åÕáèáÉ èêãèæ ÙæÕÑç + ÇäÃèä "f" Ãè êÌÈ Ùäé "f" Ãæ êÕÈÍ ÇäÍÑá ÇäÃèä ÇäÎÇÕ + ÈÇäÓñðäÓäÉ ÇäæñîÕêñÉ $a¿ </para> <para> - The current versions of PHP interpret the second assignment as - a string offset identification, so $a becomes "f", the result - of this automatic conversion however should be considered - undefined. PHP 4 introduced the new curly bracket syntax to access - characters in string, use this syntax instead of the one presented - above: + ÇäÅÕÏÇÑÇÊ ÇäÍÇäêñÉ åæ PHP ÊÊÑÌå ÇäÊÙêêæ ÇäËÇæê Ùäé Ãæñç + ÊÔÎêÕ äÅÒÇÍÉ ÓäÓäÉ æÕêñÉ ÈÍêË Ãæñ $a ÊÕÈÍ "f" èæÊêÌÉ + çÐÇ ÇäÊñÍèêä ÇäÂäêñ êÌÈ åÙ Ðäã Ãæ êÙÊÈÑ + Ùäé Ãæñç ÚêÑ åïÙîÑñîá. ÃÏÎäÊ PHP 4 ÕêÚÉ ÇäÍÇÖæÉ ÇäåÙâèáÉ ÈÚÑÖ èäèÌ + ÍÑèá ÓäÓäÉ æÕêñɬ ÇÓÊÎÏå çÐç ÇäÕñðêÚÉ ÈÏäÇ åæ Êäã ÇäåïâîÏîåÉ + áê ÇäÃÙäé: <informalexample> <programlisting role="php"><![CDATA[ <?php -$a = "abc"; // $a is a string -$a{1} = "f"; // $a is now "afc" +$a = "abc"; // $a çè ÓäÓäÉ æÕêñÉ +$a{1} = "f"; // $a çè ÇäÂæ "afc" ?> ]]></programlisting> </informalexample> - See the section titled <link linkend="language.types.string.substr">String - access by character</link> for more informaton. + ÊåîÙñîæ áê ÇäáÕä ÇäåÙæèæ <link linkend="language.types.string.substr">èäèÌ ÓäÓäÉ æÕêñÉ + åæ ÎäÇä ÍÑá</link> èÐäã åæ ÃÌä ÇäÍÕèä Ùäé åÒêÏ åæ ÇäåÙäèåÇÊ. </para> </note> <sect2 id="language.types.typecasting"> - <title>Type Casting</title> + <title>ÇäÊñîÍèêä ÇäâÓÑêñ ääÃæèÇÙ</title> <para> - Type casting in PHP works much as it does in C: the name of the - desired type is written in parentheses before the variable which - is to be cast. + êÙåä ÇäÊñîÍèêä ÇäâÓÑêñ äÏé PHP Ùäé æáÓ åæèÇä C: êïãÊÈï ÅÓå + ÇäæñîèÙ ÇäåÑÚèÈ áêç Öåæ âèÓêæ âÈä ÇäåÊÚêñðÑ ÇäÐê + êÊèÌÈ ÊÍèêäç âÓÑêÇë. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = 10; // $foo is an integer -$bar = (boolean) $foo; // $bar is a boolean +$foo = 10; // $foo çè ÙÏÏ ÕÍêÍ +$bar = (boolean) $foo; // $bar çè åæ×âê ?> ]]></programlisting> </informalexample> </para> <para> - The casts allowed are: + ÇäÊñîÍèêäÇÊ ÇäâÓÑêñÉ ÇäåÓåèÍ ÈçÇ çê: <itemizedlist> <listitem> - <simpara>(int), (integer) - cast to integer</simpara> + <simpara>(int)¬ (integer) - ääÊÍèêä âÓÑêÇ Åäé ÙÏÏ ÕÍêÍ</simpara> </listitem> <listitem> - <simpara>(bool), (boolean) - cast to boolean</simpara> + <simpara>(bool)¬ (boolean) - ääÊÍèêä âÓÑêÇ Åäé åæ×âê</simpara> </listitem> <listitem> - <simpara>(float), (double), (real) - cast to float</simpara> + <simpara>(float)¬ (double)¬ (real) - ääÊÍèêä âÓÑêÇ Åäé ÙÇÆå</simpara> </listitem> <listitem> - <simpara>(string) - cast to string</simpara> + <simpara>(string) - ääÊÍèêä âÓÑêÇ Åäé ÓäÓäÉ æÕêñÉ</simpara> </listitem> <listitem> - <simpara>(array) - cast to array</simpara> + <simpara>(array) - ääÊÍèêä âÓÑêÇ Åäé åÕáèáÉ</simpara> </listitem> <listitem> - <simpara>(object) - cast to object</simpara> + <simpara>(object) - ääÊÍèêä âÓÑêÇ Åäé ãÇÆæ</simpara> </listitem> </itemizedlist> </para> <para> - Note that tabs and spaces are allowed inside the parentheses, so - the following are functionally equivalent: + äÇÍØ Ãæñç êÓåÍ ÈÇäÌÏèäÇÊ èÇäåÓÇáÇÊ ÏÇÎä ÇäÃâèÇ ÈÍêË Ãæ + åÇ êäê êÊÔÇÈç ÙåäêÇë: <informalexample> <programlisting role="php"><![CDATA[ <?php @@ -2265,18 +2264,18 @@ </para> <note> <para> - Instead of casting a variable to string, you can also enclose - the variable in double quotes. + ÈÏäÇ åæ ÇäÊñîÍèêä ÇäâÓÑêñ äåÊÚêñðÑ Åäé ÓäÓäÉ æÕêñɬ êåãæã ÃêÖÇ ÊÖåêæ + ÇäåÊÚêñí ÏÇÎä ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ. <informalexample> <programlisting role="php"><![CDATA[ <?php -$foo = 10; // $foo is an integer -$str = "$foo"; // $str is a string -$fst = (string) $foo; // $fst is also a string +$foo = 10; // $foo çè ÙÏÏ ÕÍêÍ +$str = "$foo"; // $str çè ÓäÓäÉ æÕêñÉ +$fst = (string) $foo; // $fst çè ÃêÖÇ ÓäÓäÉ æÕêñÉ -// This prints out that "they are the same" +// ê×ÈÙ çÐÇ ÇäÊñÇäê "ÅæñçÇ åÊÔÇÈçÉ" if ($fst === $str) { - echo "they are the same"; + echo "ÅæñçÇ åÊÔÇÈçÉ"; } ?> ]]></programlisting> @@ -2284,61 +2283,61 @@ </para> </note> <para> - It may not be obvious exactly what will happen when casting - between certain types. For more info, see these sections: + êåãæ ÃäÇ êãèæ ÇäÃåÑ èÇÖÍÇ Ùäé èÌç Ïâêâ ÈÎÕèÕ åÇ ÇäÐê ÓêÍÏË ÙæÏ ÇäÊñîÍèêä ÇäâÓÑêñ + Èêæ ÈÙÖ ÇäÃæèÇÙ. äåÒêÏ åæ ÇäåÙäèåÇʬ ÊåîÙñîæ áê çÐç ÇäáÕèä: <itemizedlist> <listitem> <simpara> - <link linkend="language.types.boolean.casting">Converting to - boolean</link> + <link linkend="language.types.boolean.casting">ÇäÊñÍèêä Åäé + åæ×âê</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.integer.casting">Converting to - integer</link> + <link linkend="language.types.integer.casting">ÇäÊñÍèêä Åäé + ÙÏÏ ÕÍêÍ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.float.casting">Converting to - float</link> + <link linkend="language.types.float.casting">ÇäÊñÍèêä Åäé + ÙÇÆå</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.casting">Converting to - string</link> + <link linkend="language.types.string.casting">ÇäÊñÍèêä Åäé + ÓäÓäÉ æÕêñÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.array.casting">Converting to - array</link> + <link linkend="language.types.array.casting">ÇäÊñÍèêä Åäé + åÕáèáÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.object.casting">Converting to - object</link> + <link linkend="language.types.object.casting">ÇäÊñÍèêä Åäé + ãÇÆæ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.resource.casting">Converting to - resource</link> + <link linkend="language.types.resource.casting">ÇäÊñÍèêä Åäé + åèÑÏ</link> </simpara> </listitem> <!-- don't exist yet <listitem> - <simpara><link linkend="language.types.null.casting">Converting to + <simpara><link linkend="language.types.null.casting">ÇäÊñÍèêä Åäé &null;</link></simpara> </listitem> --> <listitem> <simpara> - <link linkend="types.comparisons">The type comparison tables</link> + <link linkend="types.comparisons">ÌÏÇèä åâÇÑæÉ ÇäÃæèÇÙ</link> </simpara> </listitem> </itemizedlist>