cvs: phpdoc /he/language expressions.xml

From: Date: Tue, 29 Jan 2002 00:21:14 +0000
Subject: cvs: phpdoc /he/language expressions.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969341689@lists.php.net to get a copy of this message
barak Mon Jan 28 19:21:14 2002 EDT Added files: /phpdoc/he/language expressions.xml Log: half of this file is Translated, Just hope that i translated the word expression as well (-:

Index: phpdoc/he/language/expressions.xml +++ phpdoc/he/language/expressions.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter id="language.expressions"> <title>Expressions - áéèåééí </title> <simpara> áéèåééí äí àçã îàáðé äééñåã äëé çùåáéí á PHP. á PHP, ëîòè ëì ãáø ùëåúáéí äåà áéèåé. äãøê äôùåèä åäîãåéé÷ú áéåúø ìäâãéø àú äîåðç "áéèåé" äéà "ëì ãáø ùéù ìå òøê".</simpara> <simpara> äöåøä äáñéñéú áéåúø ùì "áéèåéí" äí ÷áåòéí åîùúðéí. ëàùø î÷ìéãéí "$a = 5", ìîòùä îöéáéí àú äòøê '5' ìúåê $a. ìîñôø '5', éù ëîåáï àú äòøê 5, àå áîéìéí àçøåú '5' äåà áéèåé òí äòøê 5 (áî÷øä ùìðå, '5' äåà ÷áåò îñåâ îñ' ùìí ).</simpara> <simpara> àçøé ääöáä äð"ì, ëöôåé äòøê ùì $a's äåà 5. ëîå ëï, àí ééúëá áúåëðéú $b = $a, äúåöàä úäéä ëàéìå ðëúá $b = 5. áîéìéí àçøåú, $a äåà "áéèåé" òí äòøê 5 âí ëï.</simpara> <para> ãåâîàà îòè éåúø îåøëáú "ìáéèåééí" äí ôåð÷öéåú. ìîùì, äáà ðáçï àú äãåâîà äáàä: <informalexample> <programlisting role="php"> <![CDATA[ function foo () { return 5; } ]]> </programlisting> </informalexample></para> <simpara> áäðçä ùéù ìê äéëøåú òí äðåùà ùì ôåð÷öéåú (àí äúùåáä ùìéìéú úï äööä áôø÷ äãï á"ôåð÷öéåú"), àúä áèç îðéç ùäáéèåé <literal>$c = foo()</literal> äåà áéñåãå îîù ëîå ëúéáú <literal>$c = 5</literal>, åëîáï ùàúä öåã÷. ôåð÷öéåú äï áéèåééí òí äòøê ùäï òöîï îçæéøåú. îàçø å foo() îçæéø àú äòøê 5, àôùø ìàîø ùäòøê ùì äôåð÷öéä 'foo()' äåà 5. ìøåá, ôå÷ð÷öéåú ìà ø÷ îçæéøåú òøê ñèèé, àìà âí îáöòåú çéùåá ëìùäå.</simpara> <simpara> ëîáåï, òøëéí á PHP ìà çééáéí ìäéåú integers (îñôøéí ùìîéí), åìòéúéí ÷øåáåú äí ìà. PHP úåîëú áùìåùä òøëéí ñ÷àìøééí (äñáø áäîùê): îñôøéí ùìîéí, òøëé ð÷åãä öôä (îñôøéí ìà ùìîéí) åòøëé îçøåæú (òøëéí ñ÷ìøééí-scalar- äí òøëéí ùìà ðéúï ì"ùáåø" ìç÷ìéí ÷èðéí éåúø, ìäáãéì ìîùì îîòøëéí). PHP úåîëú ëîåáï áùðé ñåâé òøëéí îåøëáéí(non-scalar): îòøëéí åàåáéé÷èéí. ëì àçã îñåâ òøëéí æä éëåì ìäéåú îå÷öä ìúåê îùúðä àå àå ìäéåú îåçæø îúåê ôåð÷öéåú.</simpara> <simpara> ìôé ùòä, îùúîùéí ùì PHP/FI 2 ìà öøéëéí ìäøâéù ëì ùéðåé. áëì î÷øä, PHP ì÷çå àú "äáéèåééí" øçå÷ éåúø, îîù ëôé ùòùå ùôåú øáåú àçøåú. PHP äéà ùôä îåðçéú áéèåééí , îäáçéðä ùëîòè ëì ãáø áùôä îáåññ òì áéèåééí. àôùø ìçùåá òì òì äãåâîà ùëáø òñ÷ðå áà, '$a = 5'. ÷ì îàåã ìøàåú ùîòåøáéí áä 2 òøëéí, äòøê ùì ä÷áåò äùìí '5', åäòøê ùì $a ùìîòùä òåãëï ìäéåú âí äåà 5. ìîòï äàîú éù áî÷øä äðãåï òåã òøê ðåñó ùîòåøá, åääòøê äåà ääöáä òöîä. ääöáä òöîä éåöøú òøê âí ìòøê äîå÷öä, áî÷øä äæä 5. ìîòùä, æä àåîø ù '$a = 5', îáìé ìäúééçñ ìîä ùäåà òåùä, äåà áéèåé òí äòøê 5. ìëï, ëúéáä ùì '$b = ($a = 5)' äéà ëîå ëúéáä ùì '$a = 5; $b = 5;' (äñéîï ñîé÷åìå ';' îñîï ñéåí ùì îùôè äåøàä). îàçø åðéúåç äîùôè ðòùä îéîéï ìùîàì, àôùø ìîòùä âí ìëúåá: '$b = $a = 5'.</simpara> <simpara> ãåâîà èåáä ðåñôú ìäñáø öåøú ÷øéàú äáéèåééí: îùúîùé PHP/FI 2 åùôåú àçøåú òùåééí ìäëéø àú ÷éåîí ùì äàåôøèåøéí îùðúä++ å îùúðä--. àìå äí äàåôøèåøéí ì÷éãåí åìäçñøä. á PHP/FI 2, äîùôè '$a++' äåà çñø òøê (äåà àéðå áéèåé), åìëï àéï áå ëì ùéîåù. PHP îâéáøä àú äéëåìåú ùì àåôøèåøé ääâãìä/çéñåø òì éãé äôéëúí ìáéèåééí, îîù ëîå á C. á PHP, ëîå á C, éùðí ùðé ñåâéí ùì àåôøèåøé äâãìä pre-increment å post-increment. ùðé àìä áééñåãí îâãéìéí àú òøëé äîùúðä, åäàô÷è òì äîùúðä äåà æää. ääáãì äåà áòøê ùê äîùúðä äîåâãì. Pre-increment, ùðëúá ë '++$variable', îâãéì àú äòøê äîåâãì (PHP îâãéìä àú äòøê ìôðé ùäéà ÷åøàú àú äòøê ìëï äîåðç 'pre-increment' àå áúøâåí öåìò îùäå: "îåâãì îøàù"). Post-increment, ùðëúá ë '$variable++' îöéá àú äòøê äî÷åøé ùì $variable, ìôðé ùäåà îâãéì àåúå (PHP îâãéìä àú äòøê ùì äîùúðä àçøé ù÷øàä àú òøëå, ìôéëê äùí 'post-increment').</simpara> <simpara> ñåâ îôåó ùì áéèåééí äåà áéèåé äùååàä. áéèåééí àìå îåòøëéí ë 0 àå 1, ëìåîø ë &false; àå ë &true; (áäúàîä). PHP úåîëú á &gt; (âãåì î), &gt;= (âãåì àå ùååä ì), == (ùååä), != (ìà ùååä), &lt; (÷èï î) and &lt;= (÷èï àå ùååä ì). äùéîåù ááéèåééí àìå ðôåê áòé÷ø ááéöåò îùôèé úðàé , îäñåâ ùì <literal>if</literal> ìãåâîà.</simpara> <simpara> äñåâ äçàøåï ùì áéèåééí ù÷ééí äåà ùéìåá ùì operator-assignment expressions. You already know that if you want to increment $a by 1, you can simply write '$a++' or '++$a'. But what if you want to add more than one to it, for instance 3? You could write '$a++' multiple times, but this is obviously not a very efficient or comfortable way. A much more common practice is to write '$a = $a + 3'. '$a + 3' evaluates to the value of $a plus 3, and is assigned back into $a, which results in incrementing $a by 3. In PHP, as in several other languages like C, you can write this in a shorter way, which with time would become clearer and quicker to understand as well. Adding 3 to the current value of $a can be written '$a += 3'. This means exactly "take the value of $a, add 3 to it, and assign it back into $a". In addition to being shorter and clearer, this also results in faster execution. The value of '$a += 3', like the value of a regular assignment, is the assigned value. Notice that it is NOT 3, but the combined value of $a plus 3 (this is the value that's assigned into $a). Any two-place operator can be used in this operator-assignment mode, for example '$a -= 5' (subtract 5 from the value of $a), '$b *= 7' (multiply the value of $b by 7), etc. </simpara> <para> There is one more expression that may seem odd if you haven't seen it in other languages, the ternary conditional operator: <informalexample><programlisting> <![CDATA[ $first ? $second : $third ]]> </programlisting></informalexample> If the value of the first subexpression is &true; (non-zero), then the second subexpression is evaluated, and that is the result of the conditional expression. Otherwise, the third subexpression is evaluated, and that is the value. </para> <para> The following example should help you understand pre- and post-increment and expressions in general a bit better: <informalexample> <programlisting role="php"> <![CDATA[ function double($i) { return $i*2; } $b = $a = 5; /* assign the value five into the variable $a and $b */ $c = $a++; /* post-increment, assign original value of $a (5) to $c */ $e = $d = ++$b; /* pre-increment, assign the incremented value of $b (6) to $d and $e */ /* at this point, both $d and $e are equal to 6 */ $f = double($d++); /* assign twice the value of $d <emphasis>before</emphasis> the increment, 2*6 = 12 to $f */ $g = double(++$e); /* assign twice the value of $e <emphasis>after</emphasis> the increment, 2*7 = 14 to $g */ $h = $g += 10; /* first, $g is incremented by 10 and ends with the value of 24. the value of the assignment (24) is then assigned into $h, and $h ends with the value of 24 as well. */ ]]> </programlisting> </informalexample> </para> <simpara> In the beginning of the chapter we said that we'll be describing the various statement types, and as promised, expressions can be statements. However, not every expression is a statement. In this case, a statement has the form of 'expr' ';' that is, an expression followed by a semicolon. In '$b=$a=5;', $a=5 is a valid expression, but it's not a statement by itself. '$b=$a=5;' however is a valid statement.</simpara> <simpara> One last thing worth mentioning is the truth value of expressions. In many events, mainly in conditional execution and loops, you're not interested in the specific value of the expression, but only care about whether it means &true; or &false;. <!-- (PHP doesn't have a dedicated boolean type) : WRONG, php does. --> The constants &true; and &false; (case-insensitive) are the two possible boolean values. When necessary, an expression is automatically converted to boolean. See the <link linkend="language.types.typecasting">section about type-casting</link> for details about how. </simpara> <simpara> PHP provides a full and powerful implementation of expressions, and documenting it entirely goes beyond the scope of this manual. The above examples should give you a good idea about what expressions are and how you can construct useful expressions. Throughout the rest of this manual we'll write <replaceable>expr</replaceable> to indicate any valid PHP expression.</simpara> </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 -->
« previous php.doc (#969341689) next »