cvs: phpdoc-zh /language operators.xml
| From: | Dallas Thunder | Date: | Tue, 27 Aug 2002 07:39:15 +0000 |
| Subject: | cvs: phpdoc-zh /language operators.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-386@lists.php.net to get a copy of this message | ||
dallas Tue Aug 27 03:39:15 2002 EDT
Added files:
/phpdoc-zh/language operators.xml
Log:
Translation completed.
Index: phpdoc-zh/language/operators.xml +++ phpdoc-zh/language/operators.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.38 Maintainer: dallas Status: ready --> <chapter id="language.operators"> <title>ÔËËã·û</title> <simpara> </simpara> <sect1 id="language.operators.precedence"> <title>ÔËËã·ûÓÅÏȼ¶</title> <para> ÔËËã·ûÓÅÏȼ¶Ö¸¶¨ÁËÁ½¸ö±í´ïʽ°ó¶¨µÃÓжࡰ½ôÃÜ¡±¡£ÀýÈ磬±í´ïʽ <literal>1 + 5 * 3</literal> µÄ½á¹ûÊÇ <literal>16</literal> ¶ø²»ÊÇ <literal>18</literal> ÊÇÒòΪ³ËºÅ£¨¡°*¡±£©µÄÓÅÏȼ¶±È¼ÓºÅ£¨¡°+¡±£©¸ß¡£±ØÒªÊ±¿ÉÒÔÓÃÀ¨ºÅÀ´Ç¿ÖƸıäÓÅÏȼ¶¡£ÀýÈ磺<literal>(1 + 5) * 3</literal> µÄֵΪ <literal>18</literal>¡£ </para> <para> ϱí´ÓµÍµ½¸ßÁгöÁËÔËËã·ûµÄÓÅÏȼ¶¡£ <table> <title>ÔËËã·ûÓÅÏȼ¶</title> <tgroup cols="2"> <thead> <row> <entry>½áºÏ·½Ïò</entry> <entry>ÔËËã·û</entry> </row> </thead> <tbody> <row> <entry>×ó</entry> <entry>,</entry> </row> <row> <entry>×ó</entry> <entry>or</entry> </row> <row> <entry>×ó</entry> <entry>xor</entry> </row> <row> <entry>×ó</entry> <entry>and</entry> </row> <row> <entry>ÓÒ</entry> <entry>print</entry> </row> <row> <entry>×ó</entry> <entry> = += -= *= /= .= %= &= |= ^= ~= <<= >>= </entry> </row> <row> <entry>×ó</entry> <entry>? :</entry> </row> <row> <entry>×ó</entry> <entry>||</entry> </row> <row> <entry>×ó</entry> <entry>&&</entry> </row> <row> <entry>×ó</entry> <entry>|</entry> </row> <row> <entry>×ó</entry> <entry>^</entry> </row> <row> <entry>×ó</entry> <entry>&</entry> </row> <row> <entry>ÎÞ</entry> <entry>== != === !==</entry> </row> <row> <entry>ÎÞ</entry> <entry>< <= > >=</entry> </row> <row> <entry>×ó</entry> <entry><< >></entry> </row> <row> <entry>×ó</entry> <entry>+ - .</entry> </row> <row> <entry>×ó</entry> <entry>* / %</entry> </row> <row> <entry>ÓÒ</entry> <entry>! ~ ++ -- (int) (float) (string) (array) (object) @</entry> </row> <row> <entry>ÓÒ</entry> <entry>[</entry> </row> <row> <entry>ÎÞ</entry> <entry>new</entry> </row> </tbody> </tgroup> </table> </para> </sect1> <sect1 id="language.operators.arithmetic"> <title>ËãÊõÔËËã·û</title> <simpara> »¹¼ÇµÃѧУÀïѧµ½µÄ»ù±¾Êýѧ֪ʶÂ𣿾ͺÍËüÃÇÒ»Ñù¡£ </simpara> <table> <title>ËãÊõÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a + $b</entry> <entry>¼Ó·¨</entry> <entry>$a ºÍ $b µÄºÍ¡£</entry> </row> <row> <entry>$a - $b</entry> <entry>¼õ·¨</entry> <entry>$a ºÍ $b µÄ²î¡£</entry> </row> <row> <entry>$a * $b</entry> <entry>³Ë·¨</entry> <entry>$a ºÍ $b µÄ»ý¡£</entry> </row> <row> <entry>$a / $b</entry> <entry>³ý·¨</entry> <entry>$a ³ýÒÔ $b µÄÉÌ¡£</entry> </row> <row> <entry>$a % $b</entry> <entry>ȡģ</entry> <entry>$a ³ýÒÔ $b µÄÓàÊý¡£</entry> </row> </tbody> </tgroup> </table> <simpara> ³ýºÅ£¨¡°/¡±£©×ÜÊÇ·µ»Ø¸¡µãÊý£¬¼´Ê¹Á½¸öÔËËãÊýÊÇÕûÊý£¨»òÓÉ×Ö·û´®×ª»»³ÉµÄÕûÊý£©Ò²ÊÇÕâÑù¡£ </simpara> <!-- <simpara> The division operator ("/") returns an integer value (the ½á¹û of an integer division) if the two operands are integers (or strings that get converted to integers) and the quotient is an integer. If either operand is a floating-point value, or the operation ½á¹ûs in a non-integer value, a floating-point value is returned. </simpara> --> </sect1> <sect1 id="language.operators.assignment"> <title>¸³ÖµÔËËã·û</title> <simpara> »ù±¾µÄ¸³ÖµÔËËã·ûÊÇ¡°=¡±¡£ÄãÒ»¿ªÊ¼¿ÉÄÜ»áÒÔΪËüÊÇ¡°µÈÓÚ¡±£¬Æäʵ²»Êǵġ£Ëüʵ¼ÊÉÏÒâζ×ŰÑÓұ߱í´ïʽµÄÖµ¸³¸ø×óÔËËãÊý¡£ </simpara> <para> ¸³ÖµÔËËã±í´ïʽµÄÖµÒ²¾ÍÊÇËù¸³µÄÖµ¡£Ò²¾ÍÊÇ˵£¬¡°$a = 3¡±µÄÖµÊÇ 3¡£ÕâÑù¾Í¿ÉÒÔʹÄã×öһЩС¼¼ÇÉ£º <informalexample> <programlisting role="php"> <![CDATA[ $a = ($b = 4) + 5; // $a is equal to 9 now, and $b has been set to 4. ]]> </programlisting> </informalexample> </para> <para> ÔÚ»ù±¾¸³ÖµÔËËã·ûÖ®Í⣬»¹ÓÐÊʺÏÓÚËùÓжþÔªËãÊõºÍ×Ö·û´®ÔËËã·ûµÄ¡°×éºÍÔËËã·û¡±£¬Õâ¿ÉÒÔÈÃÄãÔÚÒ»¸ö±í´ïʽÖÐʹÓÃËüµÄÖµ²¢°Ñ±í´ïʽµÄ½á¹û¸³¸øËü£¬ÀýÈ磺 <informalexample> <programlisting role="php"> <![CDATA[ $a = 3; $a += 5; // sets $a to 8, as if we had said: $a = $a + 5; $b = "Hello "; $b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!"; ]]> </programlisting> </informalexample> </para> <para> ×¢Ò⸳ֵÔËË㽫ԱäÁ¿µÄÖµ¿½±´µ½Ð±äÁ¿ÖУ¨´«Öµ¸³Öµ£©£¬ËùÒԸıäÆäÖÐÒ»¸ö²¢²»Ó°ÏìÁíÒ»¸ö¡£ÕâÒ²ÊʺÏÓÚÄãÔÚÔÚ½ôÃÜÑ»·Öп½±´Ò»Ð©ÖµÀýÈç´óÊýÖµ¡£PHP 4 Ö§³ÖÒýÓø³Öµ£¬Óà <computeroutput>$var = &$othervar;</computeroutput> Óï·¨£¬µ«ÔÚ PHP 3 Öв»¿ÉÄÜÕâÑù×ö¡£¡°ÒýÓø³Öµ¡±Òâζ×ÅÁ½¸ö±äÁ¿¶¼Ö¸Ïòͬһ¸öÊý¾Ý£¬Ã»ÓÐÈκÎÊý¾ÝµÄ¿½±´¡£ÓйØÒýÓõĸü¶àÐÅÏ¢¼û<link linkend="language.references">ÒýÓõÄ˵Ã÷</link>¡£ </para> </sect1> <sect1 id="language.operators.bitwise"> <title>λÔËËã·û</title> <simpara> λÔËËã·ûÔÊÐí¶ÔÕûÐÍÊýÖÐÖ¸¶¨µÄλ½øÐÐÖÃλ¡£Èç¹û×óÓÒ²ÎÊý¶¼ÊÇ×Ö·û´®£¬ÔòλÔËËã·û½«²Ù×÷Õâ¸ö×Ö·û´®ÖеÄ×Ö·û¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ <?php echo 12 ^ 9; // Outputs '5' echo "12" ^ "9"; // Outputs the Backspace character (ascii 8) // ('1' (ascii 49)) ^ ('9' (ascii 57)) = #8 echo "hallo" ^ "hello"; // Outputs the ascii values #0 #4 #0 #0 #0 // 'a' ^ 'e' = #4 ?> ]]> </programlisting> </informalexample> </para> <table> <title>λÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a & $b</entry> <entry>And£¨°´Î»Ó룩</entry> <entry>½«ÔÚ $a ºÍ $b Öж¼Îª 1 µÄλÉèΪ 1¡£</entry> </row> <row> <entry>$a | $b</entry> <entry>Or£¨°´Î»»ò£©</entry> <entry>½«ÔÚ $a »òÕß $b ÖÐΪ 1 µÄλÉèΪ 1¡£</entry> </row> <row> <entry>$a ^ $b</entry> <entry>Xor£¨°´Î»Òì»ò£©</entry> <entry>½«ÔÚ $a ºÍ $b Öв»Í¬µÄλÉèΪ 1¡£</entry> </row> <row> <entry>~ $a</entry> <entry>Not£¨°´Î»·Ç£©</entry> <entry>½« $a ÖÐΪ 0 µÄλÉèΪ 1£¬·´Ö®ÒàÈ»¡£</entry> </row> <row> <entry>$a << $b</entry> <entry>Shift left£¨×óÒÆ£©</entry> <entry>½« $a ÖеÄλÏò×óÒÆ¶¯ $b ´Î£¨Ã¿Ò»´ÎÒÆ¶¯¶¼±íʾ¡°³ËÒÔ 2¡±£©¡£</entry> </row> <row> <entry>$a >> $b</entry> <entry>Shift right£¨ÓÒÒÆ£©</entry> <entry>½« $a ÖеÄλÏòÓÒÒÆ¶¯ $b ´Î£¨Ã¿Ò»´ÎÒÆ¶¯¶¼±íʾ¡°³ýÒÔ 2¡±£©¡£</entry> </row> </tbody> </tgroup> </table> </sect1> <sect1 id="language.operators.comparison"> <title>±È½ÏÔËËã·û</title> <simpara> ±È½ÏÔËËã·û£¬ÈçͬËüÃÇÃû³ÆËù°µÊ¾µÄ£¬ÔÊÐíÄã¶ÔÁ½¸öÖµ½øÐбȽϡ£ </simpara> <table> <title>±È½ÏÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a == $b</entry> <entry>µÈÓÚ</entry> <entry>&true;£¬Èç¹û $a µÈÓÚ $b¡£</entry> </row> <row> <entry>$a === $b</entry> <entry>È«µÈ</entry> <entry>&true;£¬Èç¹û $a µÈÓÚ $b£¬²¢ÇÒËüÃǵÄÀàÐÍÒ²Ïàͬ¡£(PHP 4 only)</entry> </row> <row> <entry>$a != $b</entry> <entry>²»µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b¡£</entry> </row> <row> <entry>$a <> $b</entry> <entry>²»µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b¡£</entry> </row> <row> <entry>$a !== $b</entry> <entry>·ÇÈ«µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b£¬»òÕßËüÃǵÄÀàÐͲ»Í¬¡£(PHP 4 only)</entry> </row> <row> <entry>$a < $b</entry> <entry>СÓë</entry> <entry>&true;£¬Èç¹û $a ÑϸñСÓÚ $b¡£</entry> </row> <row> <entry>$a > $b</entry> <entry>´óÓÚ</entry> <entry>&true;£¬Èç¹û $a Ñϸñ $b¡£</entry> </row> <row> <entry>$a <= $b</entry> <entry>СÓÚµÈÓÚ</entry> <entry>&true;£¬Èç¹û $a СÓÚ»òÕßµÈÓÚ $b¡£</entry> </row> <row> <entry>$a >= $b</entry> <entry>´óÓÚµÈÓÚ</entry> <entry>&true;£¬Èç¹û $a ´óÓÚ»òÕßµÈÓÚ $b¡£</entry> </row> </tbody> </tgroup> </table> <para> ÁíÍâÒ»¸öÌõ¼þÔËËã·ûÊÇ¡°?:¡±£¨»òÈýÔª£©ÔËËã·û£¬ËüºÍ C ÒÔ¼°ºÜ¶àÆäËüÓïÑԵIJÙ×÷Ò»Ñù¡£ <informalexample> <programlisting role="php"> <![CDATA[ (expr1) ? (expr2) : (expr3); ]]> </programlisting> </informalexample> Èç¹û <replaceable>expr1</replaceable> µÄֵΪ &true;£¬Ôò´Ë±í´ïʽµÄֵΪ <replaceable>expr2</replaceable>£¬Èç¹û <replaceable>expr1</replaceable> µÄֵΪ &false;£¬Ôò´Ë±í´ïʽµÄֵΪ <replaceable>expr3</replaceable>¡£ </para> </sect1> <sect1 id="language.operators.errorcontrol"> <title>´íÎó¿ØÖÆÔËËã·û</title> <simpara> PHP Ö§³ÖÒ»¸ö´íÎó¿ØÖÆÔËËã·û£º@¡£µ±½«Æä·ÅÖÃÔÚÒ»¸ö PHP ±í´ïʽ֮ǰ£¬¸Ã±í´ïʽ¿ÉÄܲúÉúµÄÈκδíÎóÐÅÏ¢¶¼±»ºöÂÔµô¡£ </simpara> <simpara> Èç¹û¼¤»îÁË <link linkend="ini.track-errors">track_errors</link> ÌØÐÔ£¬±í´ïʽËù²úÉúµÄÈκδíÎóÐÅÏ¢¶¼±»´æ·ÅÔÚÈ«¾Ö±äÁ¿ $php_errormsg ÖС£´Ë±äÁ¿ÔÚÿ´Î³ö´íʱ¶¼»á±»¸²¸Ç£¬ËùÒÔÈç¹ûÏëÓÃËüµÄ»°¾ÍÒª¾¡Ôç¼ì²é¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ <?php /* Intentional file error */ $my_file = @file ('non_existent_file') or die ("Failed opening file: error was '$php_errormsg'"); // this works for any expression, not just functions: $value = @$cache[$key]; // will not issue a notice if the index $key doesn't exist. ?> ]]> </programlisting> </informalexample> </para> <note> <simpara> @ ÔËËã·ûÖ»¶Ô±í´ïʽÓÐЧ¡£¶ÔÐÂÊÖÀ´ËµÒ»¸ö¼òµ¥µÄ¹æÔò¾ÍÊÇ£ºÈç¹ûÄãÄÜ´Óij´¦µÃµ½Öµ£¬Äã¾ÍÄÜÔÚËüÇ°Ãæ¼ÓÉÏ @ ÔËËã·û¡£ÀýÈ磬Äã¿ÉÒÔ°ÑËü·ÅÔÚ±äÁ¿£¬º¯ÊýºÍ <function>include</function> µ÷Ó㬳£Á¿£¬µÈµÈ֮ǰ¡£²»ÄܰÑËü·ÅÔÚº¯Êý»òÀàµÄ¶¨Òå֮ǰ£¬Ò²²»ÄÜÓÃÓÚÌõ¼þ½á¹¹ÀýÈç <literal>if</literal> ºÍ <literal>foreach</literal> µÈ¡£ </simpara> </note> <simpara> ²Î¼û <function>error_reporting</function>¡£ </simpara> <warning> <para> ĿǰµÄ¡°@¡±´íÎó¿ØÖÆÔËËã·ûǰ׺ÉõÖÁʹµ¼Ö½ű¾ÖÕÖ¹µÄÑÏÖØ´íÎóµÄ´íÎ󱨸æÒ²Ê§Ð§¡£ÕâÒâζ×ÅÈç¹ûÄãÔÚij¸ö²»´æÔÚ»òÀàÐÍ´íÎóµÄº¯Êýµ÷ÓÃǰÓÃÁË¡°@¡±À´ÒÖÖÆ´íÎóÐÅÏ¢£¬Äǽű¾»áûÓÐÈκμ£ÏóÏÔʾÔÒò¶øËÀÔÚÄÇÀï¡£ </para> </warning> </sect1> <sect1 id="language.operators.execution"> <title>Ö´ÐÐÔËËã·û</title> <para> PHP Ö§³ÖÒ»¸öÖ´ÐÐÔËËã·û£º·´ÒýºÅ£¨``£©¡£×¢ÒâÕâ²»Êǵ¥ÒýºÅ£¡PHP ½«³¢ÊÔ½«·´ÒýºÅÖеÄÄÚÈÝ×÷ΪÍâ¿ÇÃüÁîÀ´Ö´ÐУ¬²¢½«ÆäÊä³öÐÅÏ¢·µ»Ø£¨ÀýÈ磬¿ÉÒÔ¸³¸øÒ»¸ö±äÁ¿¶ø²»ÊǼòµ¥µØ¶ªÆúµ½±ê×¼Êä³ö£©¡£ <informalexample> <programlisting role="php"> <![CDATA[ $output = `ls -al`; echo "<pre>$output</pre>"; ]]> </programlisting> </informalexample> </para> <note> <para> ·´ÒýºÅÔËËã·ûÔÚ¼¤»îÁË <link linkend="ini.safe-mode">safe mode</link> »òÕ߹رÕÁË <function>shell_exec</function> ʱÊÇÎÞЧµÄ¡£ </para> </note> <para> ²Î¼û <function>escapeshellcmd</function>£¬<function>exec</function>£¬<function>passthru</function>£¬<function>popen</function>£¬<function>shell_exec</function> ºÍ <function>system</function>¡£ </para> </sect1> <sect1 id="language.operators.increment"> <title>¼ÓÒ»£¯¼õÒ»ÔËËã·û</title> <para> PHP Ö§³Ö C ·ç¸ñµÄǰ£¯ºó¼ÓÒ»Óë¼õÒ»ÔËËã·û¡£ </para> <table> <title>¼ÓÒ»£¯¼õÒ»ÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>Ч¹û</entry> </row> </thead> <tbody> <row> <entry>++$a</entry> <entry>ǰ¼Ó</entry> <entry>$a µÄÖµ¼ÓÒ»£¬È»ºó·µ»Ø $a¡£</entry> </row> <row> <entry>$a++</entry> <entry>ºó¼Ó</entry> <entry>·µ»Ø $a£¬È»ºó½« $a µÄÖµ¼ÓÒ»¡£</entry> </row> <row> <entry>--$a</entry> <entry>ǰ¼õ</entry> <entry>$a µÄÖµ¼õÒ»£¬ È»ºó·µ»Ø $a¡£</entry> </row> <row> <entry>$a--</entry> <entry>ºó¼õ</entry> <entry>·µ»Ø $a£¬È»ºó½« $a µÄÖµ¼õÒ»¡£</entry> </row> </tbody> </tgroup> </table> <para> Ò»¸ö¼òµ¥µÄʾÀý½Å±¾£º <informalexample> <programlisting role="php"> <![CDATA[ <?php echo "<h3>Postincrement</h3>"; $a = 5; echo "Should be 5: " . $a++ . "<br />\n"; echo "Should be 6: " . $a . "<br />\n"; echo "<h3>Preincrement</h3>"; $a = 5; echo "Should be 6: " . ++$a . "<br />\n"; echo "Should be 6: " . $a . "<br />\n"; echo "<h3>Postdecrement</h3>"; $a = 5; echo "Should be 5: " . $a-- . "<br />\n"; echo "Should be 4: " . $a . "<br />\n"; echo "<h3>Predecrement</h3>"; $a = 5; echo "Should be 4: " . --$a . "<br />\n"; echo "Should be 4: " . $a . "<br />\n"; ?> ]]> </programlisting> </informalexample> </para> </sect1> <sect1 id="language.operators.logical"> <title>Âß¼ÔËËã·û</title> <table> <title>Âß¼ÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a and $b</entry> <entry>And£¨Âß¼Ó룩</entry> <entry>&true;£¬Èç¹û $a Óë $b ¶¼Îª &true;¡£</entry> </row> <row> <entry>$a or $b</entry> <entry>Or£¨Âß¼»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;¡£</entry> </row> <row> <entry>$a xor $b</entry> <entry>Xor£¨Âß¼Òì»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;£¬µ«²»Í¬Ê±ÊÇ¡£</entry> </row> <row> <entry>! $a</entry> <entry>Not£¨Âß¼·Ç£©</entry> <entry>&true;£¬Èç¹û $a ²»Îª &true;¡£</entry> </row> <row> <entry>$a && $b</entry> <entry>And£¨Âß¼Ó룩</entry> <entry>&true;£¬Èç¹û $a Óë $b ¶¼Îª &true;¡£</entry> </row> <row> <entry>$a || $b</entry> <entry>Or£¨Âß¼»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;¡£</entry> </row> </tbody> </tgroup> </table> <simpara> ¡°Ó롱ºÍ¡°»ò¡±ÓÐÁ½ÖÖ²»Í¬ÐÎʽÔËËã·ûµÄÔÒòÊÇËüÃDzÙ×÷µÄÓÅÏȼ¶²»Í¬¡££¨¼û<link linkend="language.operators.precedence">ÔËËã·ûÓÅÏȼ¶</link>¡££© </simpara> </sect1> <sect1 id="language.operators.string"> <title>×Ö·û´®ÔËËã·û</title> <simpara> ÓÐÁ½¸ö×Ö·û´®ÔËËã·û¡£µÚÒ»¸öÊÇÁ¬½ÓÔËËã·û£¨¡°.¡±£©£¬Ëü·µ»ØÆä×óÓÒ²ÎÊýÁ¬½ÓºóµÄ×Ö·û´®¡£µÚ¶þ¸öÊÇÁ¬½Ó¸³ÖµÔËËã·û£¨¡°.=¡±£©£¬Ëü½«Óұ߲ÎÊý¸½¼Óµ½×ó±ßµÄ²ÎÊýºó¡£¸ü¶àÐÅÏ¢¼û<link linkend="language.operators.assignment">¸³ÖµÔËËã·û</link>¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ $a = "Hello "; $b = $a . "World!"; // now $b contains "Hello World!" $a = "Hello "; $a .= "World!"; // now $a contains "Hello World!" ]]> </programlisting> </informalexample> </para> </sect1> <sect1 id="language.operators.array"> <title>Êý×éÔËËã·û</title> <simpara> PHP ½öÓеÄÒ»¸öÊý×éÔËËã·ûÊÇ <literal>+</literal> ÔËËã·û¡£Ëü°ÑÓұߵÄÊý×鸽¼Óµ½×ó±ßµÄÊý×éºó£¬µ«ÊÇÖØ¸´µÄ¼üÖµ²»»á±»¸²¸Ç¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ $a = array("a" => "apple", "b" => "banana"); $b = array("a" =>"pear", "b" => "strawberry", "c" => "cherry"); $c = $a + $b; var_dump($c); ]]> </programlisting> <screen role="php"> <![CDATA[ array(3) { ["a"]=> string(5) "apple" ["b"]=> string(6) "banana" ["c"]=> string(6) "cherry" } ]]> </screen> </informalexample> </para> </sect1> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
Index: phpdoc-zh/language/operators.xml +++ phpdoc-zh/language/operators.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.38 Maintainer: dallas Status: ready --> <chapter id="language.operators"> <title>ÔËËã·û</title> <simpara> </simpara> <sect1 id="language.operators.precedence"> <title>ÔËËã·ûÓÅÏȼ¶</title> <para> ÔËËã·ûÓÅÏȼ¶Ö¸¶¨ÁËÁ½¸ö±í´ïʽ°ó¶¨µÃÓжࡰ½ôÃÜ¡±¡£ÀýÈ磬±í´ïʽ <literal>1 + 5 * 3</literal> µÄ½á¹ûÊÇ <literal>16</literal> ¶ø²»ÊÇ <literal>18</literal> ÊÇÒòΪ³ËºÅ£¨¡°*¡±£©µÄÓÅÏȼ¶±È¼ÓºÅ£¨¡°+¡±£©¸ß¡£±ØÒªÊ±¿ÉÒÔÓÃÀ¨ºÅÀ´Ç¿ÖƸıäÓÅÏȼ¶¡£ÀýÈ磺<literal>(1 + 5) * 3</literal> µÄֵΪ <literal>18</literal>¡£ </para> <para> ϱí´ÓµÍµ½¸ßÁгöÁËÔËËã·ûµÄÓÅÏȼ¶¡£ <table> <title>ÔËËã·ûÓÅÏȼ¶</title> <tgroup cols="2"> <thead> <row> <entry>½áºÏ·½Ïò</entry> <entry>ÔËËã·û</entry> </row> </thead> <tbody> <row> <entry>×ó</entry> <entry>,</entry> </row> <row> <entry>×ó</entry> <entry>or</entry> </row> <row> <entry>×ó</entry> <entry>xor</entry> </row> <row> <entry>×ó</entry> <entry>and</entry> </row> <row> <entry>ÓÒ</entry> <entry>print</entry> </row> <row> <entry>×ó</entry> <entry> = += -= *= /= .= %= &= |= ^= ~= <<= >>= </entry> </row> <row> <entry>×ó</entry> <entry>? :</entry> </row> <row> <entry>×ó</entry> <entry>||</entry> </row> <row> <entry>×ó</entry> <entry>&&</entry> </row> <row> <entry>×ó</entry> <entry>|</entry> </row> <row> <entry>×ó</entry> <entry>^</entry> </row> <row> <entry>×ó</entry> <entry>&</entry> </row> <row> <entry>ÎÞ</entry> <entry>== != === !==</entry> </row> <row> <entry>ÎÞ</entry> <entry>< <= > >=</entry> </row> <row> <entry>×ó</entry> <entry><< >></entry> </row> <row> <entry>×ó</entry> <entry>+ - .</entry> </row> <row> <entry>×ó</entry> <entry>* / %</entry> </row> <row> <entry>ÓÒ</entry> <entry>! ~ ++ -- (int) (float) (string) (array) (object) @</entry> </row> <row> <entry>ÓÒ</entry> <entry>[</entry> </row> <row> <entry>ÎÞ</entry> <entry>new</entry> </row> </tbody> </tgroup> </table> </para> </sect1> <sect1 id="language.operators.arithmetic"> <title>ËãÊõÔËËã·û</title> <simpara> »¹¼ÇµÃѧУÀïѧµ½µÄ»ù±¾Êýѧ֪ʶÂ𣿾ͺÍËüÃÇÒ»Ñù¡£ </simpara> <table> <title>ËãÊõÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a + $b</entry> <entry>¼Ó·¨</entry> <entry>$a ºÍ $b µÄºÍ¡£</entry> </row> <row> <entry>$a - $b</entry> <entry>¼õ·¨</entry> <entry>$a ºÍ $b µÄ²î¡£</entry> </row> <row> <entry>$a * $b</entry> <entry>³Ë·¨</entry> <entry>$a ºÍ $b µÄ»ý¡£</entry> </row> <row> <entry>$a / $b</entry> <entry>³ý·¨</entry> <entry>$a ³ýÒÔ $b µÄÉÌ¡£</entry> </row> <row> <entry>$a % $b</entry> <entry>ȡģ</entry> <entry>$a ³ýÒÔ $b µÄÓàÊý¡£</entry> </row> </tbody> </tgroup> </table> <simpara> ³ýºÅ£¨¡°/¡±£©×ÜÊÇ·µ»Ø¸¡µãÊý£¬¼´Ê¹Á½¸öÔËËãÊýÊÇÕûÊý£¨»òÓÉ×Ö·û´®×ª»»³ÉµÄÕûÊý£©Ò²ÊÇÕâÑù¡£ </simpara> <!-- <simpara> The division operator ("/") returns an integer value (the ½á¹û of an integer division) if the two operands are integers (or strings that get converted to integers) and the quotient is an integer. If either operand is a floating-point value, or the operation ½á¹ûs in a non-integer value, a floating-point value is returned. </simpara> --> </sect1> <sect1 id="language.operators.assignment"> <title>¸³ÖµÔËËã·û</title> <simpara> »ù±¾µÄ¸³ÖµÔËËã·ûÊÇ¡°=¡±¡£ÄãÒ»¿ªÊ¼¿ÉÄÜ»áÒÔΪËüÊÇ¡°µÈÓÚ¡±£¬Æäʵ²»Êǵġ£Ëüʵ¼ÊÉÏÒâζ×ŰÑÓұ߱í´ïʽµÄÖµ¸³¸ø×óÔËËãÊý¡£ </simpara> <para> ¸³ÖµÔËËã±í´ïʽµÄÖµÒ²¾ÍÊÇËù¸³µÄÖµ¡£Ò²¾ÍÊÇ˵£¬¡°$a = 3¡±µÄÖµÊÇ 3¡£ÕâÑù¾Í¿ÉÒÔʹÄã×öһЩС¼¼ÇÉ£º <informalexample> <programlisting role="php"> <![CDATA[ $a = ($b = 4) + 5; // $a is equal to 9 now, and $b has been set to 4. ]]> </programlisting> </informalexample> </para> <para> ÔÚ»ù±¾¸³ÖµÔËËã·ûÖ®Í⣬»¹ÓÐÊʺÏÓÚËùÓжþÔªËãÊõºÍ×Ö·û´®ÔËËã·ûµÄ¡°×éºÍÔËËã·û¡±£¬Õâ¿ÉÒÔÈÃÄãÔÚÒ»¸ö±í´ïʽÖÐʹÓÃËüµÄÖµ²¢°Ñ±í´ïʽµÄ½á¹û¸³¸øËü£¬ÀýÈ磺 <informalexample> <programlisting role="php"> <![CDATA[ $a = 3; $a += 5; // sets $a to 8, as if we had said: $a = $a + 5; $b = "Hello "; $b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!"; ]]> </programlisting> </informalexample> </para> <para> ×¢Ò⸳ֵÔËË㽫ԱäÁ¿µÄÖµ¿½±´µ½Ð±äÁ¿ÖУ¨´«Öµ¸³Öµ£©£¬ËùÒԸıäÆäÖÐÒ»¸ö²¢²»Ó°ÏìÁíÒ»¸ö¡£ÕâÒ²ÊʺÏÓÚÄãÔÚÔÚ½ôÃÜÑ»·Öп½±´Ò»Ð©ÖµÀýÈç´óÊýÖµ¡£PHP 4 Ö§³ÖÒýÓø³Öµ£¬Óà <computeroutput>$var = &$othervar;</computeroutput> Óï·¨£¬µ«ÔÚ PHP 3 Öв»¿ÉÄÜÕâÑù×ö¡£¡°ÒýÓø³Öµ¡±Òâζ×ÅÁ½¸ö±äÁ¿¶¼Ö¸Ïòͬһ¸öÊý¾Ý£¬Ã»ÓÐÈκÎÊý¾ÝµÄ¿½±´¡£ÓйØÒýÓõĸü¶àÐÅÏ¢¼û<link linkend="language.references">ÒýÓõÄ˵Ã÷</link>¡£ </para> </sect1> <sect1 id="language.operators.bitwise"> <title>λÔËËã·û</title> <simpara> λÔËËã·ûÔÊÐí¶ÔÕûÐÍÊýÖÐÖ¸¶¨µÄλ½øÐÐÖÃλ¡£Èç¹û×óÓÒ²ÎÊý¶¼ÊÇ×Ö·û´®£¬ÔòλÔËËã·û½«²Ù×÷Õâ¸ö×Ö·û´®ÖеÄ×Ö·û¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ <?php echo 12 ^ 9; // Outputs '5' echo "12" ^ "9"; // Outputs the Backspace character (ascii 8) // ('1' (ascii 49)) ^ ('9' (ascii 57)) = #8 echo "hallo" ^ "hello"; // Outputs the ascii values #0 #4 #0 #0 #0 // 'a' ^ 'e' = #4 ?> ]]> </programlisting> </informalexample> </para> <table> <title>λÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a & $b</entry> <entry>And£¨°´Î»Ó룩</entry> <entry>½«ÔÚ $a ºÍ $b Öж¼Îª 1 µÄλÉèΪ 1¡£</entry> </row> <row> <entry>$a | $b</entry> <entry>Or£¨°´Î»»ò£©</entry> <entry>½«ÔÚ $a »òÕß $b ÖÐΪ 1 µÄλÉèΪ 1¡£</entry> </row> <row> <entry>$a ^ $b</entry> <entry>Xor£¨°´Î»Òì»ò£©</entry> <entry>½«ÔÚ $a ºÍ $b Öв»Í¬µÄλÉèΪ 1¡£</entry> </row> <row> <entry>~ $a</entry> <entry>Not£¨°´Î»·Ç£©</entry> <entry>½« $a ÖÐΪ 0 µÄλÉèΪ 1£¬·´Ö®ÒàÈ»¡£</entry> </row> <row> <entry>$a << $b</entry> <entry>Shift left£¨×óÒÆ£©</entry> <entry>½« $a ÖеÄλÏò×óÒÆ¶¯ $b ´Î£¨Ã¿Ò»´ÎÒÆ¶¯¶¼±íʾ¡°³ËÒÔ 2¡±£©¡£</entry> </row> <row> <entry>$a >> $b</entry> <entry>Shift right£¨ÓÒÒÆ£©</entry> <entry>½« $a ÖеÄλÏòÓÒÒÆ¶¯ $b ´Î£¨Ã¿Ò»´ÎÒÆ¶¯¶¼±íʾ¡°³ýÒÔ 2¡±£©¡£</entry> </row> </tbody> </tgroup> </table> </sect1> <sect1 id="language.operators.comparison"> <title>±È½ÏÔËËã·û</title> <simpara> ±È½ÏÔËËã·û£¬ÈçͬËüÃÇÃû³ÆËù°µÊ¾µÄ£¬ÔÊÐíÄã¶ÔÁ½¸öÖµ½øÐбȽϡ£ </simpara> <table> <title>±È½ÏÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a == $b</entry> <entry>µÈÓÚ</entry> <entry>&true;£¬Èç¹û $a µÈÓÚ $b¡£</entry> </row> <row> <entry>$a === $b</entry> <entry>È«µÈ</entry> <entry>&true;£¬Èç¹û $a µÈÓÚ $b£¬²¢ÇÒËüÃǵÄÀàÐÍÒ²Ïàͬ¡£(PHP 4 only)</entry> </row> <row> <entry>$a != $b</entry> <entry>²»µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b¡£</entry> </row> <row> <entry>$a <> $b</entry> <entry>²»µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b¡£</entry> </row> <row> <entry>$a !== $b</entry> <entry>·ÇÈ«µÈ</entry> <entry>&true;£¬Èç¹û $a ²»µÈÓÚ $b£¬»òÕßËüÃǵÄÀàÐͲ»Í¬¡£(PHP 4 only)</entry> </row> <row> <entry>$a < $b</entry> <entry>СÓë</entry> <entry>&true;£¬Èç¹û $a ÑϸñСÓÚ $b¡£</entry> </row> <row> <entry>$a > $b</entry> <entry>´óÓÚ</entry> <entry>&true;£¬Èç¹û $a Ñϸñ $b¡£</entry> </row> <row> <entry>$a <= $b</entry> <entry>СÓÚµÈÓÚ</entry> <entry>&true;£¬Èç¹û $a СÓÚ»òÕßµÈÓÚ $b¡£</entry> </row> <row> <entry>$a >= $b</entry> <entry>´óÓÚµÈÓÚ</entry> <entry>&true;£¬Èç¹û $a ´óÓÚ»òÕßµÈÓÚ $b¡£</entry> </row> </tbody> </tgroup> </table> <para> ÁíÍâÒ»¸öÌõ¼þÔËËã·ûÊÇ¡°?:¡±£¨»òÈýÔª£©ÔËËã·û£¬ËüºÍ C ÒÔ¼°ºÜ¶àÆäËüÓïÑԵIJÙ×÷Ò»Ñù¡£ <informalexample> <programlisting role="php"> <![CDATA[ (expr1) ? (expr2) : (expr3); ]]> </programlisting> </informalexample> Èç¹û <replaceable>expr1</replaceable> µÄֵΪ &true;£¬Ôò´Ë±í´ïʽµÄֵΪ <replaceable>expr2</replaceable>£¬Èç¹û <replaceable>expr1</replaceable> µÄֵΪ &false;£¬Ôò´Ë±í´ïʽµÄֵΪ <replaceable>expr3</replaceable>¡£ </para> </sect1> <sect1 id="language.operators.errorcontrol"> <title>´íÎó¿ØÖÆÔËËã·û</title> <simpara> PHP Ö§³ÖÒ»¸ö´íÎó¿ØÖÆÔËËã·û£º@¡£µ±½«Æä·ÅÖÃÔÚÒ»¸ö PHP ±í´ïʽ֮ǰ£¬¸Ã±í´ïʽ¿ÉÄܲúÉúµÄÈκδíÎóÐÅÏ¢¶¼±»ºöÂÔµô¡£ </simpara> <simpara> Èç¹û¼¤»îÁË <link linkend="ini.track-errors">track_errors</link> ÌØÐÔ£¬±í´ïʽËù²úÉúµÄÈκδíÎóÐÅÏ¢¶¼±»´æ·ÅÔÚÈ«¾Ö±äÁ¿ $php_errormsg ÖС£´Ë±äÁ¿ÔÚÿ´Î³ö´íʱ¶¼»á±»¸²¸Ç£¬ËùÒÔÈç¹ûÏëÓÃËüµÄ»°¾ÍÒª¾¡Ôç¼ì²é¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ <?php /* Intentional file error */ $my_file = @file ('non_existent_file') or die ("Failed opening file: error was '$php_errormsg'"); // this works for any expression, not just functions: $value = @$cache[$key]; // will not issue a notice if the index $key doesn't exist. ?> ]]> </programlisting> </informalexample> </para> <note> <simpara> @ ÔËËã·ûÖ»¶Ô±í´ïʽÓÐЧ¡£¶ÔÐÂÊÖÀ´ËµÒ»¸ö¼òµ¥µÄ¹æÔò¾ÍÊÇ£ºÈç¹ûÄãÄÜ´Óij´¦µÃµ½Öµ£¬Äã¾ÍÄÜÔÚËüÇ°Ãæ¼ÓÉÏ @ ÔËËã·û¡£ÀýÈ磬Äã¿ÉÒÔ°ÑËü·ÅÔÚ±äÁ¿£¬º¯ÊýºÍ <function>include</function> µ÷Ó㬳£Á¿£¬µÈµÈ֮ǰ¡£²»ÄܰÑËü·ÅÔÚº¯Êý»òÀàµÄ¶¨Òå֮ǰ£¬Ò²²»ÄÜÓÃÓÚÌõ¼þ½á¹¹ÀýÈç <literal>if</literal> ºÍ <literal>foreach</literal> µÈ¡£ </simpara> </note> <simpara> ²Î¼û <function>error_reporting</function>¡£ </simpara> <warning> <para> ĿǰµÄ¡°@¡±´íÎó¿ØÖÆÔËËã·ûǰ׺ÉõÖÁʹµ¼Ö½ű¾ÖÕÖ¹µÄÑÏÖØ´íÎóµÄ´íÎ󱨸æÒ²Ê§Ð§¡£ÕâÒâζ×ÅÈç¹ûÄãÔÚij¸ö²»´æÔÚ»òÀàÐÍ´íÎóµÄº¯Êýµ÷ÓÃǰÓÃÁË¡°@¡±À´ÒÖÖÆ´íÎóÐÅÏ¢£¬Äǽű¾»áûÓÐÈκμ£ÏóÏÔʾÔÒò¶øËÀÔÚÄÇÀï¡£ </para> </warning> </sect1> <sect1 id="language.operators.execution"> <title>Ö´ÐÐÔËËã·û</title> <para> PHP Ö§³ÖÒ»¸öÖ´ÐÐÔËËã·û£º·´ÒýºÅ£¨``£©¡£×¢ÒâÕâ²»Êǵ¥ÒýºÅ£¡PHP ½«³¢ÊÔ½«·´ÒýºÅÖеÄÄÚÈÝ×÷ΪÍâ¿ÇÃüÁîÀ´Ö´ÐУ¬²¢½«ÆäÊä³öÐÅÏ¢·µ»Ø£¨ÀýÈ磬¿ÉÒÔ¸³¸øÒ»¸ö±äÁ¿¶ø²»ÊǼòµ¥µØ¶ªÆúµ½±ê×¼Êä³ö£©¡£ <informalexample> <programlisting role="php"> <![CDATA[ $output = `ls -al`; echo "<pre>$output</pre>"; ]]> </programlisting> </informalexample> </para> <note> <para> ·´ÒýºÅÔËËã·ûÔÚ¼¤»îÁË <link linkend="ini.safe-mode">safe mode</link> »òÕ߹رÕÁË <function>shell_exec</function> ʱÊÇÎÞЧµÄ¡£ </para> </note> <para> ²Î¼û <function>escapeshellcmd</function>£¬<function>exec</function>£¬<function>passthru</function>£¬<function>popen</function>£¬<function>shell_exec</function> ºÍ <function>system</function>¡£ </para> </sect1> <sect1 id="language.operators.increment"> <title>¼ÓÒ»£¯¼õÒ»ÔËËã·û</title> <para> PHP Ö§³Ö C ·ç¸ñµÄǰ£¯ºó¼ÓÒ»Óë¼õÒ»ÔËËã·û¡£ </para> <table> <title>¼ÓÒ»£¯¼õÒ»ÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>Ч¹û</entry> </row> </thead> <tbody> <row> <entry>++$a</entry> <entry>ǰ¼Ó</entry> <entry>$a µÄÖµ¼ÓÒ»£¬È»ºó·µ»Ø $a¡£</entry> </row> <row> <entry>$a++</entry> <entry>ºó¼Ó</entry> <entry>·µ»Ø $a£¬È»ºó½« $a µÄÖµ¼ÓÒ»¡£</entry> </row> <row> <entry>--$a</entry> <entry>ǰ¼õ</entry> <entry>$a µÄÖµ¼õÒ»£¬ È»ºó·µ»Ø $a¡£</entry> </row> <row> <entry>$a--</entry> <entry>ºó¼õ</entry> <entry>·µ»Ø $a£¬È»ºó½« $a µÄÖµ¼õÒ»¡£</entry> </row> </tbody> </tgroup> </table> <para> Ò»¸ö¼òµ¥µÄʾÀý½Å±¾£º <informalexample> <programlisting role="php"> <![CDATA[ <?php echo "<h3>Postincrement</h3>"; $a = 5; echo "Should be 5: " . $a++ . "<br />\n"; echo "Should be 6: " . $a . "<br />\n"; echo "<h3>Preincrement</h3>"; $a = 5; echo "Should be 6: " . ++$a . "<br />\n"; echo "Should be 6: " . $a . "<br />\n"; echo "<h3>Postdecrement</h3>"; $a = 5; echo "Should be 5: " . $a-- . "<br />\n"; echo "Should be 4: " . $a . "<br />\n"; echo "<h3>Predecrement</h3>"; $a = 5; echo "Should be 4: " . --$a . "<br />\n"; echo "Should be 4: " . $a . "<br />\n"; ?> ]]> </programlisting> </informalexample> </para> </sect1> <sect1 id="language.operators.logical"> <title>Âß¼ÔËËã·û</title> <table> <title>Âß¼ÔËËã·û</title> <tgroup cols="3"> <thead> <row> <entry>Àý×Ó</entry> <entry>Ãû³Æ</entry> <entry>½á¹û</entry> </row> </thead> <tbody> <row> <entry>$a and $b</entry> <entry>And£¨Âß¼Ó룩</entry> <entry>&true;£¬Èç¹û $a Óë $b ¶¼Îª &true;¡£</entry> </row> <row> <entry>$a or $b</entry> <entry>Or£¨Âß¼»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;¡£</entry> </row> <row> <entry>$a xor $b</entry> <entry>Xor£¨Âß¼Òì»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;£¬µ«²»Í¬Ê±ÊÇ¡£</entry> </row> <row> <entry>! $a</entry> <entry>Not£¨Âß¼·Ç£©</entry> <entry>&true;£¬Èç¹û $a ²»Îª &true;¡£</entry> </row> <row> <entry>$a && $b</entry> <entry>And£¨Âß¼Ó룩</entry> <entry>&true;£¬Èç¹û $a Óë $b ¶¼Îª &true;¡£</entry> </row> <row> <entry>$a || $b</entry> <entry>Or£¨Âß¼»ò£©</entry> <entry>&true;£¬Èç¹û $a »ò $b ÈÎһΪ &true;¡£</entry> </row> </tbody> </tgroup> </table> <simpara> ¡°Ó롱ºÍ¡°»ò¡±ÓÐÁ½ÖÖ²»Í¬ÐÎʽÔËËã·ûµÄÔÒòÊÇËüÃDzÙ×÷µÄÓÅÏȼ¶²»Í¬¡££¨¼û<link linkend="language.operators.precedence">ÔËËã·ûÓÅÏȼ¶</link>¡££© </simpara> </sect1> <sect1 id="language.operators.string"> <title>×Ö·û´®ÔËËã·û</title> <simpara> ÓÐÁ½¸ö×Ö·û´®ÔËËã·û¡£µÚÒ»¸öÊÇÁ¬½ÓÔËËã·û£¨¡°.¡±£©£¬Ëü·µ»ØÆä×óÓÒ²ÎÊýÁ¬½ÓºóµÄ×Ö·û´®¡£µÚ¶þ¸öÊÇÁ¬½Ó¸³ÖµÔËËã·û£¨¡°.=¡±£©£¬Ëü½«Óұ߲ÎÊý¸½¼Óµ½×ó±ßµÄ²ÎÊýºó¡£¸ü¶àÐÅÏ¢¼û<link linkend="language.operators.assignment">¸³ÖµÔËËã·û</link>¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ $a = "Hello "; $b = $a . "World!"; // now $b contains "Hello World!" $a = "Hello "; $a .= "World!"; // now $a contains "Hello World!" ]]> </programlisting> </informalexample> </para> </sect1> <sect1 id="language.operators.array"> <title>Êý×éÔËËã·û</title> <simpara> PHP ½öÓеÄÒ»¸öÊý×éÔËËã·ûÊÇ <literal>+</literal> ÔËËã·û¡£Ëü°ÑÓұߵÄÊý×鸽¼Óµ½×ó±ßµÄÊý×éºó£¬µ«ÊÇÖØ¸´µÄ¼üÖµ²»»á±»¸²¸Ç¡£ </simpara> <para> <informalexample> <programlisting role="php"> <![CDATA[ $a = array("a" => "apple", "b" => "banana"); $b = array("a" =>"pear", "b" => "strawberry", "c" => "cherry"); $c = $a + $b; var_dump($c); ]]> </programlisting> <screen role="php"> <![CDATA[ array(3) { ["a"]=> string(5) "apple" ["b"]=> string(6) "banana" ["c"]=> string(6) "cherry" } ]]> </screen> </informalexample> </para> </sect1> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->