cvs: phpdoc-ar /language types.xml
| From: | Hafid Benhadria | Date: | Wed, 03 Sep 2003 15:27:43 +0000 |
| Subject: | cvs: phpdoc-ar /language types.xml | ||
| Groups: | php.doc.ar | ||
| Request: | Send a blank email to doc-ar+get-568@lists.php.net to get a copy of this message | ||
hafid Wed Sep 3 11:27:43 2003 EDT
Modified files:
/phpdoc-ar/language types.xml
Log:
3rd Partial Translation. Still EN-1.123 compliant.
Index: phpdoc-ar/language/types.xml diff -u phpdoc-ar/language/types.xml:1.2 phpdoc-ar/language/types.xml:1.3 --- phpdoc-ar/language/types.xml:1.2 Mon Sep 1 16:59:39 2003 +++ phpdoc-ar/language/types.xml Wed Sep 3 11:27:43 2003 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-6"?> -<!-- $Revision: 1.2 $ --> -<!-- EN-Revision: 1.123 Maintainer: hafid Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.123 Maintainer: hafid Status: working --> <chapter id="language.types"> <title>ÇäÃæèÇÙ</title> <sect1 id="language.types.intro"> @@ -145,6 +145,7 @@ ÈÇÙÊÈÇÑ ÃæçÇ ÊØçÑ ÃåËäÉ äåâÇÑæÇÊ åÊÙäâÉ ÈÃæèÇÙ åÊÙÏÏÉ. </simpara> </sect1> + <sect1 id="language.types.boolean"> <title>Booleans - Çäåæ×âêÇÊ</title> <simpara> @@ -349,7 +350,7 @@ var_dump($large_number); // output: float(2147483648) -// this goes also for hexadecimal specified integers: +// êæ×Èâ çÐÇ ÃêÖÇ Ùäé ÇäÃÙÏÇÏ ÇäÕÍêÍÉ ÇäåÍÏÏÉ ÓÊÙÔÑêÇë: var_dump( 0x80000000 ); // output: float(2147483648) @@ -521,84 +522,84 @@ </para> </warning> <sect2 id="language.types.float.casting"> - <title>Converting to float</title> + <title>ÇäÊÍèêä Åäé ÙÇÆå</title> <para> - For information on when and how strings are converted to floats, - see the section titled <link linkend="language.types.string.conversion">String - conversion to numbers</link>. For values of other types, the conversion - is the same as if the value would have been converted to integer - and then to float. See the <link linkend="language.types.integer.casting">Converting - to integer</link> section for more information. + äåÒêÏ åæ ÇäåÙäèåÇÊ Ùæ ÊèâêÊ èãêáêÉ ÊÍèêä ÇäÓäÇÓä ÇäæñÕêñÉ Åäé ÙèÇÆå¬ + Ç×äÙ Ùäé ÇäáÕä ÇäåÙæèæ <link linkend="language.types.string.conversion">ÊÍèêä ÇäÓäÇÓä ÇäæñÕêñÉ + Åäé ÃÙÏÇÏ</link>. ääâêå åæ ÐèÇÊ ÇäÃæèÇÙ ÇäÃÎÑé¬ áÅæ ÇäÊÍèêä + çè æáÓç åËäåÇ äè Êå ÊÍèêä ÇäâêåÉ Åäé ÙÏÏ ÕÍêÍ + èåæ Ëå Åäé ÙÇÆå. ÇÓÊÙÑÖ åâ×Ù <link linkend="language.types.integer.casting">ÇäÊÍèêä + Åäé ÙÏÏ ÕÍêÍ</link> äåÒêÏ åæ ÇäåÙäèåÇÊ. </para> </sect2> </sect1> <sect1 id="language.types.string"> - <title>Strings</title> + <title>ÇäÓäÇÓä ÇäæÕêÉ</title> <para> - A <type>string</type> is series of characters. In PHP, - a character is the same as a byte, that is, there are exactly - 256 different characters possible. This also implies that PHP - has no native support of Unicode. See <function>utf8_encode</function> - and <function>utf8_decode</function> for some Unicode support. + Çäà<type>ÓäÓäÉ ÇäæñÕêñÉ</type> çê ÙÈÇÑÉ Ùæ åÊÓäÓäÉ åæ ÇäÃÍÑá. áê PHP¬ + ÇäÍÑá çè æáÓ ÇäÔêÁ ãÇäÈÇêʬ èåæç áÅæñç êåãæ Ãæ ÊèÌÏ Ùäé èÌç ÇäÊÏâêâ + 256 ÍÑáÇ åÎÊäáÇ. êæ×èê çÐÇ ÃêÖÇ Ùäé Ãæñ PHP + äÇ ÊÊèáÑ Ùäé ÏÙå ÃÕäêñ ääàUnicode. ÇÓÊÙÑÖ <function>utf8_encode</function> + è <function>utf8_decode</function> ääÍÕèä Ùäé ÈÙÖ åæ ÏÙå Unicode. </para> <note> <simpara> - It is no problem for a string to become very large. - There is no practical bound to the size - of strings imposed by PHP, so there is no reason at all - to worry about long strings. + äêÓÊ çæÇã åæ åÔãäÉ áê Ãæ ÊÕÈÍ ÓäÓäÉ æÕêñÉ åÇ ãÈêÑÉ ÌÏÇë. + äêÓ çæÇã ÍÏ Ùåäêñ äÍÌå + ÇäÓäÓäÇÊ ÇäæñÕêñÉ êãèæ åáÑèÖÇ åæ âÈä PHP¬ äÐäã áäêÓ çæÇã åæ ÓÈÈ Ùäé ÇäÅ×äÇâ + ääâäâ ÈÎÕèÕ ÇäÓñðäÓäÇÊ ÇäæñÕêñÉ Çä×èêäÉ. </simpara> </note> <sect2 id="language.types.string.syntax"> - <title>Syntax</title> + <title>ÇäÕñêÚÉ</title> <para> - A string literal can be specified in three different - ways. + êåãæ ÊÍÏêÏ ÍÑáêÉ ÓäÓäÉ æÕêñÉ ÈËäÇË ×Ñâ + åÎÊäáÉ. <itemizedlist> <listitem> <simpara> - <link linkend="language.types.string.syntax.single">single quoted</link> + <link linkend="language.types.string.syntax.single">ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.syntax.double">double quoted</link> + <link linkend="language.types.string.syntax.double">ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.syntax.heredoc">heredoc syntax</link> + <link linkend="language.types.string.syntax.heredoc">ÕêÚÉ heredoc</link> </simpara> </listitem> </itemizedlist> </para> <sect3 id="language.types.string.syntax.single"> - <title>Single quoted</title> + <title>ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ</title> <para> - The easiest way to specify a simple string is to - enclose it in single quotes (the character <literal>'</literal>). + ÊÊåËä ÃÓçä ×ÑêâÉ äÊÍÏêÏ ÓäÓäÉ æÕêñÉ ÈÓê×É áê + ÊÖåêæçÇ Öåæ ÙäÇåÊê ÊæÕêÕ åáÑÏÉ (ÇäÍÑá <literal>'</literal>). </para> <para> - To specify a literal single - quote, you will need to escape it with a backslash - (<literal>\</literal>), like in many other languages. - If a backslash needs to occur before a single quote or at - the end of the string, you need to double it. - Note that if you try to escape any - other character, the backslash will also be printed! So - usually there is no need to escape the backslash itself. + äÊÍÏêÏ ÙäÇåÉ ÊæÕêÕ åáÑÏÉ èÇÍÏɬ + ÊÍÊÇÌ äÊÃåêæçÇ ÈèÇÓ×É Î× åÇÆä åÊÑÇÌÙ + (<literal>\</literal>)¬ åËäåÇ ÇäÍÇä áê ÙÏÉ äÚÇÊ ÃÎÑé. + ÅÐÇ ãÇæ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ ÈÍÇÌÉ äÃæ ê×Ñà âÈä ÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ Ãè ÙæÏ + æçÇêÉ ÇäÓñäÓäÉ ÇäæñÕêñɬ áÅæñã ÊÍÊÇÌ äåÖÇÙáÊç. + ÇæÊÈç Åäé Ãæñç ÅÐÇ ãæÊ ÊÍÇèä ÊÃåêæ Ãê + ÍÑá ÂÎѬ áÅæñ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ Óêï×ÈÙ ÃêÖÇ! äÐä㬠áÅæñç + äÇ ÍÇÌÉ ÙÇÏÉë äÊÃåêæ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ æáÓç. <note> <simpara> - In PHP 3, a warning will - be issued at the <literal>E_NOTICE</literal> level when this - happens. + áê PHP 3¬ êÊå ÇÓÊÕÏÇÑ ÊÍÐêÑ + ÙæÏ åÓÊèé <literal>E_NOTICE</literal> áê ÍÇäÉ ÍÏèË + çÐÇ. </simpara> </note> <note> <simpara> - Unlike the two other syntaxes, <link linkend="language.variables">variables</link> and escape sequences - for special characters will <emphasis>not</emphasis> be expanded - when they occur in single quoted strings. + Ùäé ÙãÓ ÇäÕêÚÊêæ ÇäÃÎÑêêæ¬ áÅæñ <link linkend="language.variables">ÇäåÊÚêÑÇÊ</link> èÇäÊÊÇÈÙÇÊ ÇäÊñåäÕêñÉ + ÇäåÊÙäâÉ ÈÇäÃÍÑá ÇäÎÇÕÉ <emphasis>äæ</emphasis> êÊå ÊèÓêÙçÇ + ÙæÏåÇ Ê×Ñà áê ÓäÓäÇÊ æÕêÉ åÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ. </simpara> </note> <informalexample> @@ -630,19 +631,19 @@ </para> </sect3> <sect3 id="language.types.string.syntax.double"> - <title>Double quoted</title> + <title>ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ</title> <para> - If the string is enclosed in double-quotes ("), - PHP understands more escape sequences for special - characters: + ÅÐÇ Êå ÊÖåêæ ÇäÓñäÓäÉ ÇäæñÕêñÉ Öåæ ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ (")¬ + áÅæñ PHP ÓÊáçå èÈÔãä ÃáÖä ÇäÊÊÇÈÙÇÊ ÇäÊåäÕêÉ ÇäåÊÙäâÉ ÈÇäÃÍÑá + ÇäÎÇÕÉ: </para> <table> - <title>Escaped characters</title> + <title>ÇäÍÑèá ÇäåÄåæÉ</title> <tgroup cols="2"> <thead> <row> - <entry>sequence</entry> - <entry>meaning</entry> + <entry>ÇäÊÊÇÈÙ</entry> + <entry>ÇäåÙæé</entry> </row> </thead> <tbody> @@ -650,45 +651,45 @@ <entry> <literal>\n</literal> </entry> - <entry>linefeed (LF or 0x0A (10) in ASCII)</entry> + <entry>linefeed - ÅâÍÇå ÇäÓñ×Ñ (LF Ãè 0x0A (10) áê ASCII)</entry> </row> <row> <entry> <literal>\r</literal> </entry> - <entry>carriage return (CR or 0x0D (13) in ASCII)</entry> + <entry>carriage return - ÇäÙèÏÉ Åäé ÇäçÇåÔ (CR Ãè 0x0D (13) áê ASCII)</entry> </row> <row> <entry> <literal>\t</literal> </entry> - <entry>horizontal tab (HT or 0x09 (9) in ASCII)</entry> + <entry>horizontal tab - ÌÏèäÉ ÃáâêñÉ (HT Ãè 0x09 (9) áê ASCII)</entry> </row> <row> <entry> <literal>\\</literal> </entry> - <entry>backslash</entry> + <entry>ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ</entry> </row> <row> <entry> <literal>\$</literal> </entry> - <entry>dollar sign</entry> + <entry>ÑåÒ ÇäÏèäÇÑ</entry> </row> <row> <entry> <literal>\"</literal> </entry> - <entry>double-quote</entry> + <entry>ÙäÇåÇÊ ÇäÊæÕêÕ ÇäåÒÏèÌÉ</entry> </row> <row> <entry> <literal>\[0-7]{1,3}</literal> </entry> <entry> - the sequence of characters matching the regular - expression is a character in octal notation + Åæ ÊÊÇÈÙ ÇäÃÍÑá ÇäÐê êÊèÇáâ åÙ ÇäÙÈÇÑÉ ÇäÅÙÊêÇÏêñÉ + çè ÍÑá ÈÇäÊñæâê× ÇäËïåÇæêñ </entry> </row> <row> @@ -696,78 +697,78 @@ <literal>\x[0-9A-Fa-f]{1,2}</literal> </entry> <entry> - the sequence of characters matching the regular - expression is a character in hexadecimal notation + Åæñ ÊÊÇÈÙ ÇäÃÍÑá ÇäÐê êÊèÇáâ åÙ ÇäÙÈÇÑÉ ÇäÅÙÊêÇÏêñÉ + çè ÍÑá ÈÇäÊæâê× ÇäÓÊÙÔÑêñ </entry> </row> </tbody> </tgroup> </table> <para> - Again, if you try to escape any other character, the - backslash will be printed too! + åæ ÌÏêϬ ÅÐÇ ÍÇèäÊ ÊÃåêæ Ãê ÍÑá ÂÎѬ áÅæ + ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ ÓÊåå ×ÈÇÙÊç ÃêÖÇ! </para> <para> - But the most important feature of double-quoted strings - is the fact that variable names will be expanded. - See <link linkend="language.types.string.parsing">string - parsing</link> for details. + äãæ ÇäåêÒÉ ÇäÃãËÑ ÃçåêÉ äÏé ÇäÓäÓäÇÊ ÇäæÕêÉ ÇäåÍÇ×É ÈÙäÇåÇÊ ÇäÊæÕêÕ ÇäåÒÏèÌÉ + çê èÇâÙ Ãæ ÃÓåÇÁ ÇäåÊÚêÑÇÊ ÓêÊå ÊèÓêÙçÇ. + ÇÓÊÙÑÖ <link linkend="language.types.string.parsing">ÊáÓêÑ + ÇäÓñðäÓäÉ ÇäæñÕêñÉ</link> äåÒêÏ åæ ÇäÊñáÇÕêä. </para> </sect3> <sect3 id="language.types.string.syntax.heredoc"> <title>Heredoc</title> <simpara> - Another way to delimit strings is by using heredoc syntax - ("<<<"). One should provide an identifier after - <literal><<<</literal>, then the string, and then the - same identifier to close the quotation. + çæÇã ×ÑêâÉ ÃÎÑé äÊÍÏêÏ ÇäÓäÇÓä ÇäæñÕêñÉ èÊÊåËä áê ÇÓÊÎÏÇå ÕêÚÉ heredoc + ("<<<"). êÌÈ Ùäé ÇäåÑÁ Ãæ êïèîáñðÑ åïÙÑñðáÇëë ÈÙÏ + <literal><<<</literal>¬ èåæ Ëå ÇäÓñðäÓäÉ ÇäæñÕêñÉ Ëå + æáÓ ÇäåïÙÑñðá äÅÚäÇâ ÇäÊñæÕêÕ. </simpara> <simpara> - The closing identifier <emphasis>must</emphasis> begin in the - first column of the line. Also, the identifier used must follow - the same naming rules as any other label in PHP: it must contain - only alphanumeric characters and underscores, and must start with - a non-digit character or underscore. + Åæñ åïÙÑñðá ÇäÅÚäÇâ <emphasis>êÌÈ</emphasis> Ãæ êÈÏà áê + ÇäÙåèÏ ÇäÃèä åæ ÇäñÓ×Ñ. ãÐä㬠áÅæñ ÇäåïÙÑñðá ÇäåÓÊÎÏå êÌÈ Ãæ êÊÈÙ + æáÓ âèÇÙÏ ÇäÊñÓåêÉ åËäåÇ ÇäÍÇä ÈÇäæÓÈÉ äÃêÉ ÊÓåêÉ áê PHP: êÌÈ Ãæ ÊÍÊèê + áâ× Ùäé ÃÍÑá ÃÈÌÏÙÏÏêñÉ èÔÑ×ÇÊ ÓáäêñÉ èêÌÈ Ãæ ÊÈÏà + ÈÍÑá ÚêÑ Ñâåêñ Ãè ÔÑ×É ÓáäêñÉ. </simpara> <warning> <simpara> - It is very important to note that the line with the closing - identifier contains no other characters, except - <emphasis>possibly</emphasis> a semicolon (<literal>;</literal>). - That means especially that the identifier - <emphasis>may not be indented</emphasis>, and there - may not be any spaces or tabs after or before the semicolon. - It's also important to realize that the first character before - the closing identifier must be a newline as defined by your - operating system. This is <literal>\r</literal> on Macintosh - for example. + Åæñç äåæ ÔÏÉ ÇäÃçåêÉ ÈåãÇæ Ãæ æÔêÑ Åäé Ãæ ÇäÓñ×Ñ ÇäÐê Èç åïÙîÑñðá ÇäÅÚäÇâ + äÇ êÖå Ãê ÍÑá ÂÎѬ áêåÇ ÙÏÇ + <emphasis>äÑÈåÇ</emphasis> áÇÕäÉ åæâè×É (<literal>;</literal>). + êÙæê çÐÇ ÎÇÕÉ Ãæ ÇäåïÙîÑñðá + <emphasis>äÇ êåãæ ÅÒÇÍÊç</emphasis> èäÇ êåãæ + Ãæ Êãèæ çæÇã ÃêÉ åÓÇáÉ Ãè ÌÏèäÉ ÈÙÏ Ãè âÈä ÇäáÇÕäÉ Çäåæâè×É. + Åæñç äåæ ÇäÃçåêÉ ÈåãÇæ ÃêÖÇ ÅÏÑÇã Ãæ ÇäÍÑá ÇäÃèä âÈä + åïÙîÑñðá ÇäÅÚäÇâ êÌÈ Ãæ êãèæ Ó×ÑÇë ÌÏêÏÇë åËäåÇ Êå ÊÙÑêáç åæ âÈä + æØÇåã ÇäÊñÔÚêäêñ. êÊåËä çÐÇ áê <literal>\r</literal> Ùäé Macintosh¬ + Ùäé ÓÈêä ÇäåËÇä. </simpara> <simpara> - If this rule is broken and the closing identifier is not "clean" - then it's not considered to be a closing identifier and PHP - will continue looking for one. If in this case a proper closing - identifier is not found then a parse error will result with the - line number being at the end of the script. + ÅÐÇ ãïÓðÑÊ çÐç ÇäâÇÙÏÉ èäå êãæ åïÙîÑñðá ÇäÅÚäÇâ "æØêáÇë"¬ + ÍêæçÇ äæ êÙÊÈÑ Ùäé Ãæñç åïÙîÑñðá ÅÚäÇâ èPHP + ÓÊÓÊåÑ áê ÇäÈÍË Ùæ ÅÍÏé åÙÑñðáÇÊ ÇäÅÚäÇâ. áê çÐç ÇäÍÇäɬ ÅÐÇ ÌÑé èäå êÊå ÅêÌÇÏ åïÙîÑñðá ÇäÅÚäÇâ ÇääÇÆâ + áÓêæÊÌ Ùæ Ðäã Î×à áê ÇäÊñáÓêÑ åÑáèâ + ÈÑâå ÇäÓñ×Ñ ÇäåÊèÇÌÏ ÙæÏ æçÇêÉ ÇäÎÇ×è×. </simpara> </warning> <para> - Heredoc text behaves just like a double-quoted string, without - the double-quotes. This means that you do not need to escape quotes - in your here docs, but you can still use the escape codes listed - above. Variables are expanded, but the same care must be taken - when expressing complex variables inside a here doc as with - strings. + Åæ æÕ Heredoc êÊÕÑá åËä ÓäÓäÉ æÕêñÉ åïÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌɬ äãæ ÈÏèæ + ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ. êÙæê çÐÇ Ãæñã äÓÊ ÈÍÇÌÉ äÊÃåêæ ÙäÇåÇÊ ÇäÊæÕêÕ + áê here docs ÇäÎÇÕÉ È㬠äãæ äÇ êÒÇä ÈÅåãÇæã ÇÓÊÎÏÇå ÔêáÑÇÊ ÇäÊåäñïÕ ÇäåïÏèñîæÉ áê äÇÆÍÉ + ÈÇäÃÙäé. ÇäåÊÚêÑÇÊ êÊå ÊèÓêÙçÇ äãæ æáÓ ÇäÙæÇêÉ êÌÈ Ãæ Êïèäé + ÙæÏ ÇäÊÙÈêÑ Ùæ åÊÚêÑÇÊ åÙâÏÉ Öåæ here doc åËäåÇ ÇäÍÇä åÙ + ÇäÓñäÇÓä ÇäæñÕêñÉ. <example> - <title>Heredoc string quoting example</title> + <title>åËÇä Ùæ ÊæÕêÕ ÓäÓäÉ æÕêñÉ Heredoc</title> <programlisting role="php"><![CDATA[ <?php $str = <<<EOD -Example of string -spanning multiple lines -using heredoc syntax. +åËÇä Ùæ ÓäÓäÉ æÕêÉ +ÊåÊÏ Ùäé ÙÏÉ ÃÓ×Ñ +ÈÇÓÊÎÏÇå ÕêÚÉ heredoc. EOD; -/* More complex example, with variables. */ +/* åËÇä ÃãËÑ ÊÙâêÏÇ êÊÖåæ åÊÚêÑÇÊ. */ class foo { var $foo; @@ -781,12 +782,12 @@ } $foo = new foo(); -$name = 'MyName'; +$name = 'ÍáêØ'; echo <<<EOT -My name is "$name". I am printing some $foo->foo. -Now, I am printing some {$foo->bar[1]}. -This should print a capital 'A': \x41 +ÅÓåê "$name". ÃæÇ ÈÕÏÏ ×ÈÇÙÉ ÈÙÖ $foo->foo. +ÇäÂæ¬ ÃæÇ ÈÕÏÏ ×ÈÇÙÉ ÈÙÖ {$foo->bar[1]}. +äÇ ÈÏ Ãæ çÐÇ Óê×ÈÙ ÍÑáÇ ãÈêÑÇ 'A': \x41 EOT; ?> ]]></programlisting> @@ -794,57 +795,57 @@ </para> <note> <para> - Heredoc support was added in PHP 4. + ÃïÖðêá ÏÙå Heredoc áê PHP 4. </para> </note> </sect3> <sect3 id="language.types.string.parsing"> - <title>Variable parsing</title> + <title>ÊáÓêÑ ÇäåÊÚêÑÇÊ</title> <simpara> - When a string is specified in double quotes or with - heredoc, <link linkend="language.variables">variables</link> are - parsed within it. + ÙæÏåÇ êÊå ÊÍÏêÏ ÓäÓäÉ æÕêñÉ Öåæ ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ Ãè ÈÕÍÈÉ + heredoc¬ áÅæñç êÊå ÊáÓêÑ <link linkend="language.variables">ÇäåÊÚêÑÇÊ </link> + ÖåæçÇ. </simpara> <simpara> - There are two types of syntax: a - <link linkend="language.types.string.parsing.simple">simple</link> - one and a - <link linkend="language.types.string.parsing.complex">complex</link> - one. - The simple syntax is the most common and convenient. It provides a way - to parse a variable, an <type>array</type> value, or an <type> - object</type> property. + çæÇã æèÙêæ åæ ÇäÕêÚ: + èÇÍÏÉ <link linkend="language.types.string.parsing.simple">ÈÓê×É</link> + èèÇÍÏÉ + <link linkend="language.types.string.parsing.complex">åÙâÏÉ</link> + . + ÇäÕêÚÉ ÇäÈÓê×É çê ÇäÃãËÑ ÔêèÙÇë èÇäÃãËÑ åäÇÁåÉ. çê ÊèáÑ ×ÑêâÉ + äÊáÓêÑ åÊÚêÑ åǬ âêåÉ <type>åÕáèáÉ</type> åÇ Ãè ÎÇÕêÉ <type> + ãÇÆæ</type>. </simpara> <simpara> - The complex syntax was introduced in PHP 4, and can be recognised - by the curly braces surrounding the expression. + ÃïÏÑÌÊ ÇäÕêÚÉ ÇäåÙâÏÉ áê PHP 4 èêåãæ ÇäÊÙÑá ÙäêçÇ + åæ ÎäÇä âèÓêæ åÙâèáêæ êÍê×Çæ ÈÇäÙÈÇÑÉ. </simpara> <sect4 id="language.types.string.parsing.simple"> - <title>Simple syntax</title> + <title>ÇäÕñêÚÉ ÇäåÙâÏÉ</title> <simpara> - If a dollar sign (<literal>$</literal>) is encountered, the - parser will greedily take as many tokens as possible to form a - valid variable name. Enclose the variable name in curly - braces if you want to explicitly specify the end of the name. + ÅÐÇ åÇ ÕèÏá ÑåÒ ÏèäÇÑ (<literal>$</literal>)¬ áÅæñ + ÇäåïáîÓñðÑ êÃÎÐ ÔÇÑÇÊ Èæçå èÈâÏÑ åÇ êÓÊ×êÙ äÊÔãêä + ÅÓå åÊÚêÑ ÕÇäÍ. ÃÍ× ÅÓå ÇäåÊÚêÑ ÈâèÓêæ åÙâèáêæ + ÅÐÇ ÃÑÏÊ ÈÔãä ÕÑêÍ ÊÍÏêÏ æçÇêÉ ÇäÅÓå. </simpara> <informalexample> <programlisting role="php"><![CDATA[ <?php $beer = 'Heineken'; -echo "$beer's taste is great"; // works, "'" is an invalid character for varnames -echo "He drank some $beers"; // won't work, 's' is a valid character for varnames -echo "He drank some ${beer}s"; // works -echo "He drank some {$beer}s"; // works +echo "$beer's taste is great"; // êÙåä¬ "'" çè ÍÑá ÚêÑ ÕÇäÍ äÃÓåÇÁ ÇäåÊÚêÑÇÊ +echo "He drank some $beers"; // äæ êÙåä¬ 's' çè ÍÑá ÕÇäÍ äÃÓåÇÁ ÇäåÊÚêÑÇÊ +echo "He drank some ${beer}s"; // êÙåä +echo "He drank some {$beer}s"; // êÙåä ?> ]]></programlisting> </informalexample> <simpara> - Similarly, you can also have an <type>array</type> index or an <type> - object</type> property parsed. With array indices, the closing square - bracket (<literal>]</literal>) marks the end of the index. For - object properties the same rules apply as to simple variables, - though with object properties there doesn't exist a trick like - the one with variables. + Ùäé æÍè ååÇËä¬ êåãæã ÃêÖÇ ÇäÍÕèä Ùäé áçÑÓ <type>array</type> Ãè ÎÇÕêÉ <type> + ãÇÆæ</type> åáÓÑêæ. ÈèÇÓ×É áçÇÑÓ ÇäåÕáèáÇʬ áÅæñ ÃâèÇÓ ÇäÅÚäÇâ + ÇäåÑÈÙÉ (<literal>]</literal>) ÊÔêÑ Åäé æçÇêÉ ÇäáçÑÓ. ÈÇäæñÓÈÉ + äÎÇÕêÇÊ ÇäãÇÆæÇʬ áÅæñ æáÓ ÇäâèÇÙÏ Êæ×Èâ åËäåÇ ÇäÍÇä ÈÇäæñÓÈÉ ääåÊÚêÑÇÊ ÇäÈÓê×ɬ + èäè Ãæñç åÙ ÎÇÕêÇÊ ÇäãÇÆæÇÊ äÇ ÊèÌÏ ÍêäÉ åËä + Êäã ÇäÊê åÙ ÇäåÊÚêÑÇÊ. <!-- XXX isn't &true; :(, this would be the trick Also, the same trick with curly-braces works if you @@ -854,35 +855,35 @@ <informalexample> <programlisting role="php"><![CDATA[ <?php -// These examples are specific to using arrays inside of strings. -// When outside of a string, always quote your array string keys -// and do not use {braces} when outside of strings either. +// çÐç ÇäÃåËäÉ ÊÎÕ ÇÓÊÎÏÇå ÇäåÕáèáÇÊ Öåæ ÓäÇÓä æÕêñÉ +// ÙæÏåÇ Êãèæ ÎÇÑÌ ÓäÓäÉ æÕêñɬ âå ÏÇÆåÇë ÈÊæÕêÕ åáÇÊêÍ ÇäÓäÓäÉ ÇäæÕêÉ ÇäÎÇÕÉ ÈÇäåÕáèáÉ äÏêã +// èäÇ ÊÓÊÎÏå ãÐäã {ÇäÍÇÖæÊêæ} ÙæÏåÇ Êãèæ ÎÇÑÌ ÇäÓäÇÓä ÇäæñÕêñÉ. -// Let's show all errors +// 俨çÑ ãä ÇäÃÎ×ÇÁ error_reporting(E_ALL); $fruits = array('strawberry' => 'red', 'banana' => 'yellow'); -// Works but note that this works differently outside string-quotes +// êÙåä äãæ ÇæÊÈç Åäé Ãæñ çÐÇ êÙåä ÈÔãä åÎÊäá áê ÎÇÑÌ ÊæÕêÕÇÊ ÇäÓñäÓäÉ ÇäæñÕêñÉ echo "A banana is $fruits[banana]."; -// Works +// êÙåä echo "A banana is {$fruits['banana']}."; -// Works but PHP looks for a constant named banana first -// as described below. +// êÙåä äãæ PHP ÊÈÍË ÃèäÇ Ùæ ËÇÈÊ êÏÙé banana +// åËäåÇ çè åèÕèá áê ÇäÃÓáä. echo "A banana is {$fruits[banana]}."; -// Won't work, use braces. This results in a parse error. +// äæ êÙåä¬ ÇÓÊÎÏå ÇäÍÇÖæÊêæ. êÄÏê çÐÇ Åäé Î×à ÊáÓêÑêñ. echo "A banana is $fruits['banana']."; -// Works +// êÙåä echo "A banana is " . $fruits['banana'] . "."; -// Works +// êÙåä echo "This square is $square->width meters broad."; -// Won't work. For a solution, see the complex syntax. +// äæ êÙåä. ääæØÑ áê Íä¬ ÇÓÊÙÑÖ ÇäÕêÚÉ ÇäåÙâÏÉ. echo "This square is $square->width00 centimeters broad."; ?> ]]><!-- XXX this won't work: @@ -894,7 +895,7 @@ </programlisting> </informalexample> <simpara> - For anything more complex, you should use the complex syntax. + äÃê ÔêÁ çè ÃãËÑ ÊÙâêÏǬ êÌÈ Ùäêã ÇÓÊÎÏÇå ÇäÕêÚÉ ÇäåÙâÏÉ. </simpara> </sect4> <sect4 id="language.types.string.parsing.complex"> @@ -1077,6 +1078,7 @@ functions <function>print_r</function> and <function>var_dump</function> for better ways to print out values for debugging. </para> + <para> You can also convert PHP values to strings to store them permanently. This method is called serialization, and can be done with the function
Index: phpdoc-ar/language/types.xml diff -u phpdoc-ar/language/types.xml:1.2 phpdoc-ar/language/types.xml:1.3 --- phpdoc-ar/language/types.xml:1.2 Mon Sep 1 16:59:39 2003 +++ phpdoc-ar/language/types.xml Wed Sep 3 11:27:43 2003 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-6"?> -<!-- $Revision: 1.2 $ --> -<!-- EN-Revision: 1.123 Maintainer: hafid Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.123 Maintainer: hafid Status: working --> <chapter id="language.types"> <title>ÇäÃæèÇÙ</title> <sect1 id="language.types.intro"> @@ -145,6 +145,7 @@ ÈÇÙÊÈÇÑ ÃæçÇ ÊØçÑ ÃåËäÉ äåâÇÑæÇÊ åÊÙäâÉ ÈÃæèÇÙ åÊÙÏÏÉ. </simpara> </sect1> + <sect1 id="language.types.boolean"> <title>Booleans - Çäåæ×âêÇÊ</title> <simpara> @@ -349,7 +350,7 @@ var_dump($large_number); // output: float(2147483648) -// this goes also for hexadecimal specified integers: +// êæ×Èâ çÐÇ ÃêÖÇ Ùäé ÇäÃÙÏÇÏ ÇäÕÍêÍÉ ÇäåÍÏÏÉ ÓÊÙÔÑêÇë: var_dump( 0x80000000 ); // output: float(2147483648) @@ -521,84 +522,84 @@ </para> </warning> <sect2 id="language.types.float.casting"> - <title>Converting to float</title> + <title>ÇäÊÍèêä Åäé ÙÇÆå</title> <para> - For information on when and how strings are converted to floats, - see the section titled <link linkend="language.types.string.conversion">String - conversion to numbers</link>. For values of other types, the conversion - is the same as if the value would have been converted to integer - and then to float. See the <link linkend="language.types.integer.casting">Converting - to integer</link> section for more information. + äåÒêÏ åæ ÇäåÙäèåÇÊ Ùæ ÊèâêÊ èãêáêÉ ÊÍèêä ÇäÓäÇÓä ÇäæñÕêñÉ Åäé ÙèÇÆå¬ + Ç×äÙ Ùäé ÇäáÕä ÇäåÙæèæ <link linkend="language.types.string.conversion">ÊÍèêä ÇäÓäÇÓä ÇäæñÕêñÉ + Åäé ÃÙÏÇÏ</link>. ääâêå åæ ÐèÇÊ ÇäÃæèÇÙ ÇäÃÎÑé¬ áÅæ ÇäÊÍèêä + çè æáÓç åËäåÇ äè Êå ÊÍèêä ÇäâêåÉ Åäé ÙÏÏ ÕÍêÍ + èåæ Ëå Åäé ÙÇÆå. ÇÓÊÙÑÖ åâ×Ù <link linkend="language.types.integer.casting">ÇäÊÍèêä + Åäé ÙÏÏ ÕÍêÍ</link> äåÒêÏ åæ ÇäåÙäèåÇÊ. </para> </sect2> </sect1> <sect1 id="language.types.string"> - <title>Strings</title> + <title>ÇäÓäÇÓä ÇäæÕêÉ</title> <para> - A <type>string</type> is series of characters. In PHP, - a character is the same as a byte, that is, there are exactly - 256 different characters possible. This also implies that PHP - has no native support of Unicode. See <function>utf8_encode</function> - and <function>utf8_decode</function> for some Unicode support. + Çäà<type>ÓäÓäÉ ÇäæñÕêñÉ</type> çê ÙÈÇÑÉ Ùæ åÊÓäÓäÉ åæ ÇäÃÍÑá. áê PHP¬ + ÇäÍÑá çè æáÓ ÇäÔêÁ ãÇäÈÇêʬ èåæç áÅæñç êåãæ Ãæ ÊèÌÏ Ùäé èÌç ÇäÊÏâêâ + 256 ÍÑáÇ åÎÊäáÇ. êæ×èê çÐÇ ÃêÖÇ Ùäé Ãæñ PHP + äÇ ÊÊèáÑ Ùäé ÏÙå ÃÕäêñ ääàUnicode. ÇÓÊÙÑÖ <function>utf8_encode</function> + è <function>utf8_decode</function> ääÍÕèä Ùäé ÈÙÖ åæ ÏÙå Unicode. </para> <note> <simpara> - It is no problem for a string to become very large. - There is no practical bound to the size - of strings imposed by PHP, so there is no reason at all - to worry about long strings. + äêÓÊ çæÇã åæ åÔãäÉ áê Ãæ ÊÕÈÍ ÓäÓäÉ æÕêñÉ åÇ ãÈêÑÉ ÌÏÇë. + äêÓ çæÇã ÍÏ Ùåäêñ äÍÌå + ÇäÓäÓäÇÊ ÇäæñÕêñÉ êãèæ åáÑèÖÇ åæ âÈä PHP¬ äÐäã áäêÓ çæÇã åæ ÓÈÈ Ùäé ÇäÅ×äÇâ + ääâäâ ÈÎÕèÕ ÇäÓñðäÓäÇÊ ÇäæñÕêñÉ Çä×èêäÉ. </simpara> </note> <sect2 id="language.types.string.syntax"> - <title>Syntax</title> + <title>ÇäÕñêÚÉ</title> <para> - A string literal can be specified in three different - ways. + êåãæ ÊÍÏêÏ ÍÑáêÉ ÓäÓäÉ æÕêñÉ ÈËäÇË ×Ñâ + åÎÊäáÉ. <itemizedlist> <listitem> <simpara> - <link linkend="language.types.string.syntax.single">single quoted</link> + <link linkend="language.types.string.syntax.single">ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.syntax.double">double quoted</link> + <link linkend="language.types.string.syntax.double">ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ</link> </simpara> </listitem> <listitem> <simpara> - <link linkend="language.types.string.syntax.heredoc">heredoc syntax</link> + <link linkend="language.types.string.syntax.heredoc">ÕêÚÉ heredoc</link> </simpara> </listitem> </itemizedlist> </para> <sect3 id="language.types.string.syntax.single"> - <title>Single quoted</title> + <title>ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ</title> <para> - The easiest way to specify a simple string is to - enclose it in single quotes (the character <literal>'</literal>). + ÊÊåËä ÃÓçä ×ÑêâÉ äÊÍÏêÏ ÓäÓäÉ æÕêñÉ ÈÓê×É áê + ÊÖåêæçÇ Öåæ ÙäÇåÊê ÊæÕêÕ åáÑÏÉ (ÇäÍÑá <literal>'</literal>). </para> <para> - To specify a literal single - quote, you will need to escape it with a backslash - (<literal>\</literal>), like in many other languages. - If a backslash needs to occur before a single quote or at - the end of the string, you need to double it. - Note that if you try to escape any - other character, the backslash will also be printed! So - usually there is no need to escape the backslash itself. + äÊÍÏêÏ ÙäÇåÉ ÊæÕêÕ åáÑÏÉ èÇÍÏɬ + ÊÍÊÇÌ äÊÃåêæçÇ ÈèÇÓ×É Î× åÇÆä åÊÑÇÌÙ + (<literal>\</literal>)¬ åËäåÇ ÇäÍÇä áê ÙÏÉ äÚÇÊ ÃÎÑé. + ÅÐÇ ãÇæ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ ÈÍÇÌÉ äÃæ ê×Ñà âÈä ÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ Ãè ÙæÏ + æçÇêÉ ÇäÓñäÓäÉ ÇäæñÕêñɬ áÅæñã ÊÍÊÇÌ äåÖÇÙáÊç. + ÇæÊÈç Åäé Ãæñç ÅÐÇ ãæÊ ÊÍÇèä ÊÃåêæ Ãê + ÍÑá ÂÎѬ áÅæñ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ Óêï×ÈÙ ÃêÖÇ! äÐä㬠áÅæñç + äÇ ÍÇÌÉ ÙÇÏÉë äÊÃåêæ ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ æáÓç. <note> <simpara> - In PHP 3, a warning will - be issued at the <literal>E_NOTICE</literal> level when this - happens. + áê PHP 3¬ êÊå ÇÓÊÕÏÇÑ ÊÍÐêÑ + ÙæÏ åÓÊèé <literal>E_NOTICE</literal> áê ÍÇäÉ ÍÏèË + çÐÇ. </simpara> </note> <note> <simpara> - Unlike the two other syntaxes, <link linkend="language.variables">variables</link> and escape sequences - for special characters will <emphasis>not</emphasis> be expanded - when they occur in single quoted strings. + Ùäé ÙãÓ ÇäÕêÚÊêæ ÇäÃÎÑêêæ¬ áÅæñ <link linkend="language.variables">ÇäåÊÚêÑÇÊ</link> èÇäÊÊÇÈÙÇÊ ÇäÊñåäÕêñÉ + ÇäåÊÙäâÉ ÈÇäÃÍÑá ÇäÎÇÕÉ <emphasis>äæ</emphasis> êÊå ÊèÓêÙçÇ + ÙæÏåÇ Ê×Ñà áê ÓäÓäÇÊ æÕêÉ åÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åáÑÏÉ. </simpara> </note> <informalexample> @@ -630,19 +631,19 @@ </para> </sect3> <sect3 id="language.types.string.syntax.double"> - <title>Double quoted</title> + <title>ÇäÅÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ</title> <para> - If the string is enclosed in double-quotes ("), - PHP understands more escape sequences for special - characters: + ÅÐÇ Êå ÊÖåêæ ÇäÓñäÓäÉ ÇäæñÕêñÉ Öåæ ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ (")¬ + áÅæñ PHP ÓÊáçå èÈÔãä ÃáÖä ÇäÊÊÇÈÙÇÊ ÇäÊåäÕêÉ ÇäåÊÙäâÉ ÈÇäÃÍÑá + ÇäÎÇÕÉ: </para> <table> - <title>Escaped characters</title> + <title>ÇäÍÑèá ÇäåÄåæÉ</title> <tgroup cols="2"> <thead> <row> - <entry>sequence</entry> - <entry>meaning</entry> + <entry>ÇäÊÊÇÈÙ</entry> + <entry>ÇäåÙæé</entry> </row> </thead> <tbody> @@ -650,45 +651,45 @@ <entry> <literal>\n</literal> </entry> - <entry>linefeed (LF or 0x0A (10) in ASCII)</entry> + <entry>linefeed - ÅâÍÇå ÇäÓñ×Ñ (LF Ãè 0x0A (10) áê ASCII)</entry> </row> <row> <entry> <literal>\r</literal> </entry> - <entry>carriage return (CR or 0x0D (13) in ASCII)</entry> + <entry>carriage return - ÇäÙèÏÉ Åäé ÇäçÇåÔ (CR Ãè 0x0D (13) áê ASCII)</entry> </row> <row> <entry> <literal>\t</literal> </entry> - <entry>horizontal tab (HT or 0x09 (9) in ASCII)</entry> + <entry>horizontal tab - ÌÏèäÉ ÃáâêñÉ (HT Ãè 0x09 (9) áê ASCII)</entry> </row> <row> <entry> <literal>\\</literal> </entry> - <entry>backslash</entry> + <entry>ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ</entry> </row> <row> <entry> <literal>\$</literal> </entry> - <entry>dollar sign</entry> + <entry>ÑåÒ ÇäÏèäÇÑ</entry> </row> <row> <entry> <literal>\"</literal> </entry> - <entry>double-quote</entry> + <entry>ÙäÇåÇÊ ÇäÊæÕêÕ ÇäåÒÏèÌÉ</entry> </row> <row> <entry> <literal>\[0-7]{1,3}</literal> </entry> <entry> - the sequence of characters matching the regular - expression is a character in octal notation + Åæ ÊÊÇÈÙ ÇäÃÍÑá ÇäÐê êÊèÇáâ åÙ ÇäÙÈÇÑÉ ÇäÅÙÊêÇÏêñÉ + çè ÍÑá ÈÇäÊñæâê× ÇäËïåÇæêñ </entry> </row> <row> @@ -696,78 +697,78 @@ <literal>\x[0-9A-Fa-f]{1,2}</literal> </entry> <entry> - the sequence of characters matching the regular - expression is a character in hexadecimal notation + Åæñ ÊÊÇÈÙ ÇäÃÍÑá ÇäÐê êÊèÇáâ åÙ ÇäÙÈÇÑÉ ÇäÅÙÊêÇÏêñÉ + çè ÍÑá ÈÇäÊæâê× ÇäÓÊÙÔÑêñ </entry> </row> </tbody> </tgroup> </table> <para> - Again, if you try to escape any other character, the - backslash will be printed too! + åæ ÌÏêϬ ÅÐÇ ÍÇèäÊ ÊÃåêæ Ãê ÍÑá ÂÎѬ áÅæ + ÇäÎ× ÇäåÇÆä ÇäåÊÑÇÌÙ ÓÊåå ×ÈÇÙÊç ÃêÖÇ! </para> <para> - But the most important feature of double-quoted strings - is the fact that variable names will be expanded. - See <link linkend="language.types.string.parsing">string - parsing</link> for details. + äãæ ÇäåêÒÉ ÇäÃãËÑ ÃçåêÉ äÏé ÇäÓäÓäÇÊ ÇäæÕêÉ ÇäåÍÇ×É ÈÙäÇåÇÊ ÇäÊæÕêÕ ÇäåÒÏèÌÉ + çê èÇâÙ Ãæ ÃÓåÇÁ ÇäåÊÚêÑÇÊ ÓêÊå ÊèÓêÙçÇ. + ÇÓÊÙÑÖ <link linkend="language.types.string.parsing">ÊáÓêÑ + ÇäÓñðäÓäÉ ÇäæñÕêñÉ</link> äåÒêÏ åæ ÇäÊñáÇÕêä. </para> </sect3> <sect3 id="language.types.string.syntax.heredoc"> <title>Heredoc</title> <simpara> - Another way to delimit strings is by using heredoc syntax - ("<<<"). One should provide an identifier after - <literal><<<</literal>, then the string, and then the - same identifier to close the quotation. + çæÇã ×ÑêâÉ ÃÎÑé äÊÍÏêÏ ÇäÓäÇÓä ÇäæñÕêñÉ èÊÊåËä áê ÇÓÊÎÏÇå ÕêÚÉ heredoc + ("<<<"). êÌÈ Ùäé ÇäåÑÁ Ãæ êïèîáñðÑ åïÙÑñðáÇëë ÈÙÏ + <literal><<<</literal>¬ èåæ Ëå ÇäÓñðäÓäÉ ÇäæñÕêñÉ Ëå + æáÓ ÇäåïÙÑñðá äÅÚäÇâ ÇäÊñæÕêÕ. </simpara> <simpara> - The closing identifier <emphasis>must</emphasis> begin in the - first column of the line. Also, the identifier used must follow - the same naming rules as any other label in PHP: it must contain - only alphanumeric characters and underscores, and must start with - a non-digit character or underscore. + Åæñ åïÙÑñðá ÇäÅÚäÇâ <emphasis>êÌÈ</emphasis> Ãæ êÈÏà áê + ÇäÙåèÏ ÇäÃèä åæ ÇäñÓ×Ñ. ãÐä㬠áÅæñ ÇäåïÙÑñðá ÇäåÓÊÎÏå êÌÈ Ãæ êÊÈÙ + æáÓ âèÇÙÏ ÇäÊñÓåêÉ åËäåÇ ÇäÍÇä ÈÇäæÓÈÉ äÃêÉ ÊÓåêÉ áê PHP: êÌÈ Ãæ ÊÍÊèê + áâ× Ùäé ÃÍÑá ÃÈÌÏÙÏÏêñÉ èÔÑ×ÇÊ ÓáäêñÉ èêÌÈ Ãæ ÊÈÏà + ÈÍÑá ÚêÑ Ñâåêñ Ãè ÔÑ×É ÓáäêñÉ. </simpara> <warning> <simpara> - It is very important to note that the line with the closing - identifier contains no other characters, except - <emphasis>possibly</emphasis> a semicolon (<literal>;</literal>). - That means especially that the identifier - <emphasis>may not be indented</emphasis>, and there - may not be any spaces or tabs after or before the semicolon. - It's also important to realize that the first character before - the closing identifier must be a newline as defined by your - operating system. This is <literal>\r</literal> on Macintosh - for example. + Åæñç äåæ ÔÏÉ ÇäÃçåêÉ ÈåãÇæ Ãæ æÔêÑ Åäé Ãæ ÇäÓñ×Ñ ÇäÐê Èç åïÙîÑñðá ÇäÅÚäÇâ + äÇ êÖå Ãê ÍÑá ÂÎѬ áêåÇ ÙÏÇ + <emphasis>äÑÈåÇ</emphasis> áÇÕäÉ åæâè×É (<literal>;</literal>). + êÙæê çÐÇ ÎÇÕÉ Ãæ ÇäåïÙîÑñðá + <emphasis>äÇ êåãæ ÅÒÇÍÊç</emphasis> èäÇ êåãæ + Ãæ Êãèæ çæÇã ÃêÉ åÓÇáÉ Ãè ÌÏèäÉ ÈÙÏ Ãè âÈä ÇäáÇÕäÉ Çäåæâè×É. + Åæñç äåæ ÇäÃçåêÉ ÈåãÇæ ÃêÖÇ ÅÏÑÇã Ãæ ÇäÍÑá ÇäÃèä âÈä + åïÙîÑñðá ÇäÅÚäÇâ êÌÈ Ãæ êãèæ Ó×ÑÇë ÌÏêÏÇë åËäåÇ Êå ÊÙÑêáç åæ âÈä + æØÇåã ÇäÊñÔÚêäêñ. êÊåËä çÐÇ áê <literal>\r</literal> Ùäé Macintosh¬ + Ùäé ÓÈêä ÇäåËÇä. </simpara> <simpara> - If this rule is broken and the closing identifier is not "clean" - then it's not considered to be a closing identifier and PHP - will continue looking for one. If in this case a proper closing - identifier is not found then a parse error will result with the - line number being at the end of the script. + ÅÐÇ ãïÓðÑÊ çÐç ÇäâÇÙÏÉ èäå êãæ åïÙîÑñðá ÇäÅÚäÇâ "æØêáÇë"¬ + ÍêæçÇ äæ êÙÊÈÑ Ùäé Ãæñç åïÙîÑñðá ÅÚäÇâ èPHP + ÓÊÓÊåÑ áê ÇäÈÍË Ùæ ÅÍÏé åÙÑñðáÇÊ ÇäÅÚäÇâ. áê çÐç ÇäÍÇäɬ ÅÐÇ ÌÑé èäå êÊå ÅêÌÇÏ åïÙîÑñðá ÇäÅÚäÇâ ÇääÇÆâ + áÓêæÊÌ Ùæ Ðäã Î×à áê ÇäÊñáÓêÑ åÑáèâ + ÈÑâå ÇäÓñ×Ñ ÇäåÊèÇÌÏ ÙæÏ æçÇêÉ ÇäÎÇ×è×. </simpara> </warning> <para> - Heredoc text behaves just like a double-quoted string, without - the double-quotes. This means that you do not need to escape quotes - in your here docs, but you can still use the escape codes listed - above. Variables are expanded, but the same care must be taken - when expressing complex variables inside a here doc as with - strings. + Åæ æÕ Heredoc êÊÕÑá åËä ÓäÓäÉ æÕêñÉ åïÍÇ×É ÈÙäÇåÇÊ ÊæÕêÕ åÒÏèÌɬ äãæ ÈÏèæ + ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ. êÙæê çÐÇ Ãæñã äÓÊ ÈÍÇÌÉ äÊÃåêæ ÙäÇåÇÊ ÇäÊæÕêÕ + áê here docs ÇäÎÇÕÉ È㬠äãæ äÇ êÒÇä ÈÅåãÇæã ÇÓÊÎÏÇå ÔêáÑÇÊ ÇäÊåäñïÕ ÇäåïÏèñîæÉ áê äÇÆÍÉ + ÈÇäÃÙäé. ÇäåÊÚêÑÇÊ êÊå ÊèÓêÙçÇ äãæ æáÓ ÇäÙæÇêÉ êÌÈ Ãæ Êïèäé + ÙæÏ ÇäÊÙÈêÑ Ùæ åÊÚêÑÇÊ åÙâÏÉ Öåæ here doc åËäåÇ ÇäÍÇä åÙ + ÇäÓñäÇÓä ÇäæñÕêñÉ. <example> - <title>Heredoc string quoting example</title> + <title>åËÇä Ùæ ÊæÕêÕ ÓäÓäÉ æÕêñÉ Heredoc</title> <programlisting role="php"><![CDATA[ <?php $str = <<<EOD -Example of string -spanning multiple lines -using heredoc syntax. +åËÇä Ùæ ÓäÓäÉ æÕêÉ +ÊåÊÏ Ùäé ÙÏÉ ÃÓ×Ñ +ÈÇÓÊÎÏÇå ÕêÚÉ heredoc. EOD; -/* More complex example, with variables. */ +/* åËÇä ÃãËÑ ÊÙâêÏÇ êÊÖåæ åÊÚêÑÇÊ. */ class foo { var $foo; @@ -781,12 +782,12 @@ } $foo = new foo(); -$name = 'MyName'; +$name = 'ÍáêØ'; echo <<<EOT -My name is "$name". I am printing some $foo->foo. -Now, I am printing some {$foo->bar[1]}. -This should print a capital 'A': \x41 +ÅÓåê "$name". ÃæÇ ÈÕÏÏ ×ÈÇÙÉ ÈÙÖ $foo->foo. +ÇäÂæ¬ ÃæÇ ÈÕÏÏ ×ÈÇÙÉ ÈÙÖ {$foo->bar[1]}. +äÇ ÈÏ Ãæ çÐÇ Óê×ÈÙ ÍÑáÇ ãÈêÑÇ 'A': \x41 EOT; ?> ]]></programlisting> @@ -794,57 +795,57 @@ </para> <note> <para> - Heredoc support was added in PHP 4. + ÃïÖðêá ÏÙå Heredoc áê PHP 4. </para> </note> </sect3> <sect3 id="language.types.string.parsing"> - <title>Variable parsing</title> + <title>ÊáÓêÑ ÇäåÊÚêÑÇÊ</title> <simpara> - When a string is specified in double quotes or with - heredoc, <link linkend="language.variables">variables</link> are - parsed within it. + ÙæÏåÇ êÊå ÊÍÏêÏ ÓäÓäÉ æÕêñÉ Öåæ ÙäÇåÇÊ ÊæÕêÕ åÒÏèÌÉ Ãè ÈÕÍÈÉ + heredoc¬ áÅæñç êÊå ÊáÓêÑ <link linkend="language.variables">ÇäåÊÚêÑÇÊ </link> + ÖåæçÇ. </simpara> <simpara> - There are two types of syntax: a - <link linkend="language.types.string.parsing.simple">simple</link> - one and a - <link linkend="language.types.string.parsing.complex">complex</link> - one. - The simple syntax is the most common and convenient. It provides a way - to parse a variable, an <type>array</type> value, or an <type> - object</type> property. + çæÇã æèÙêæ åæ ÇäÕêÚ: + èÇÍÏÉ <link linkend="language.types.string.parsing.simple">ÈÓê×É</link> + èèÇÍÏÉ + <link linkend="language.types.string.parsing.complex">åÙâÏÉ</link> + . + ÇäÕêÚÉ ÇäÈÓê×É çê ÇäÃãËÑ ÔêèÙÇë èÇäÃãËÑ åäÇÁåÉ. çê ÊèáÑ ×ÑêâÉ + äÊáÓêÑ åÊÚêÑ åǬ âêåÉ <type>åÕáèáÉ</type> åÇ Ãè ÎÇÕêÉ <type> + ãÇÆæ</type>. </simpara> <simpara> - The complex syntax was introduced in PHP 4, and can be recognised - by the curly braces surrounding the expression. + ÃïÏÑÌÊ ÇäÕêÚÉ ÇäåÙâÏÉ áê PHP 4 èêåãæ ÇäÊÙÑá ÙäêçÇ + åæ ÎäÇä âèÓêæ åÙâèáêæ êÍê×Çæ ÈÇäÙÈÇÑÉ. </simpara> <sect4 id="language.types.string.parsing.simple"> - <title>Simple syntax</title> + <title>ÇäÕñêÚÉ ÇäåÙâÏÉ</title> <simpara> - If a dollar sign (<literal>$</literal>) is encountered, the - parser will greedily take as many tokens as possible to form a - valid variable name. Enclose the variable name in curly - braces if you want to explicitly specify the end of the name. + ÅÐÇ åÇ ÕèÏá ÑåÒ ÏèäÇÑ (<literal>$</literal>)¬ áÅæñ + ÇäåïáîÓñðÑ êÃÎÐ ÔÇÑÇÊ Èæçå èÈâÏÑ åÇ êÓÊ×êÙ äÊÔãêä + ÅÓå åÊÚêÑ ÕÇäÍ. ÃÍ× ÅÓå ÇäåÊÚêÑ ÈâèÓêæ åÙâèáêæ + ÅÐÇ ÃÑÏÊ ÈÔãä ÕÑêÍ ÊÍÏêÏ æçÇêÉ ÇäÅÓå. </simpara> <informalexample> <programlisting role="php"><![CDATA[ <?php $beer = 'Heineken'; -echo "$beer's taste is great"; // works, "'" is an invalid character for varnames -echo "He drank some $beers"; // won't work, 's' is a valid character for varnames -echo "He drank some ${beer}s"; // works -echo "He drank some {$beer}s"; // works +echo "$beer's taste is great"; // êÙåä¬ "'" çè ÍÑá ÚêÑ ÕÇäÍ äÃÓåÇÁ ÇäåÊÚêÑÇÊ +echo "He drank some $beers"; // äæ êÙåä¬ 's' çè ÍÑá ÕÇäÍ äÃÓåÇÁ ÇäåÊÚêÑÇÊ +echo "He drank some ${beer}s"; // êÙåä +echo "He drank some {$beer}s"; // êÙåä ?> ]]></programlisting> </informalexample> <simpara> - Similarly, you can also have an <type>array</type> index or an <type> - object</type> property parsed. With array indices, the closing square - bracket (<literal>]</literal>) marks the end of the index. For - object properties the same rules apply as to simple variables, - though with object properties there doesn't exist a trick like - the one with variables. + Ùäé æÍè ååÇËä¬ êåãæã ÃêÖÇ ÇäÍÕèä Ùäé áçÑÓ <type>array</type> Ãè ÎÇÕêÉ <type> + ãÇÆæ</type> åáÓÑêæ. ÈèÇÓ×É áçÇÑÓ ÇäåÕáèáÇʬ áÅæñ ÃâèÇÓ ÇäÅÚäÇâ + ÇäåÑÈÙÉ (<literal>]</literal>) ÊÔêÑ Åäé æçÇêÉ ÇäáçÑÓ. ÈÇäæñÓÈÉ + äÎÇÕêÇÊ ÇäãÇÆæÇʬ áÅæñ æáÓ ÇäâèÇÙÏ Êæ×Èâ åËäåÇ ÇäÍÇä ÈÇäæñÓÈÉ ääåÊÚêÑÇÊ ÇäÈÓê×ɬ + èäè Ãæñç åÙ ÎÇÕêÇÊ ÇäãÇÆæÇÊ äÇ ÊèÌÏ ÍêäÉ åËä + Êäã ÇäÊê åÙ ÇäåÊÚêÑÇÊ. <!-- XXX isn't &true; :(, this would be the trick Also, the same trick with curly-braces works if you @@ -854,35 +855,35 @@ <informalexample> <programlisting role="php"><![CDATA[ <?php -// These examples are specific to using arrays inside of strings. -// When outside of a string, always quote your array string keys -// and do not use {braces} when outside of strings either. +// çÐç ÇäÃåËäÉ ÊÎÕ ÇÓÊÎÏÇå ÇäåÕáèáÇÊ Öåæ ÓäÇÓä æÕêñÉ +// ÙæÏåÇ Êãèæ ÎÇÑÌ ÓäÓäÉ æÕêñɬ âå ÏÇÆåÇë ÈÊæÕêÕ åáÇÊêÍ ÇäÓäÓäÉ ÇäæÕêÉ ÇäÎÇÕÉ ÈÇäåÕáèáÉ äÏêã +// èäÇ ÊÓÊÎÏå ãÐäã {ÇäÍÇÖæÊêæ} ÙæÏåÇ Êãèæ ÎÇÑÌ ÇäÓäÇÓä ÇäæñÕêñÉ. -// Let's show all errors +// 俨çÑ ãä ÇäÃÎ×ÇÁ error_reporting(E_ALL); $fruits = array('strawberry' => 'red', 'banana' => 'yellow'); -// Works but note that this works differently outside string-quotes +// êÙåä äãæ ÇæÊÈç Åäé Ãæñ çÐÇ êÙåä ÈÔãä åÎÊäá áê ÎÇÑÌ ÊæÕêÕÇÊ ÇäÓñäÓäÉ ÇäæñÕêñÉ echo "A banana is $fruits[banana]."; -// Works +// êÙåä echo "A banana is {$fruits['banana']}."; -// Works but PHP looks for a constant named banana first -// as described below. +// êÙåä äãæ PHP ÊÈÍË ÃèäÇ Ùæ ËÇÈÊ êÏÙé banana +// åËäåÇ çè åèÕèá áê ÇäÃÓáä. echo "A banana is {$fruits[banana]}."; -// Won't work, use braces. This results in a parse error. +// äæ êÙåä¬ ÇÓÊÎÏå ÇäÍÇÖæÊêæ. êÄÏê çÐÇ Åäé Î×à ÊáÓêÑêñ. echo "A banana is $fruits['banana']."; -// Works +// êÙåä echo "A banana is " . $fruits['banana'] . "."; -// Works +// êÙåä echo "This square is $square->width meters broad."; -// Won't work. For a solution, see the complex syntax. +// äæ êÙåä. ääæØÑ áê Íä¬ ÇÓÊÙÑÖ ÇäÕêÚÉ ÇäåÙâÏÉ. echo "This square is $square->width00 centimeters broad."; ?> ]]><!-- XXX this won't work: @@ -894,7 +895,7 @@ </programlisting> </informalexample> <simpara> - For anything more complex, you should use the complex syntax. + äÃê ÔêÁ çè ÃãËÑ ÊÙâêÏǬ êÌÈ Ùäêã ÇÓÊÎÏÇå ÇäÕêÚÉ ÇäåÙâÏÉ. </simpara> </sect4> <sect4 id="language.types.string.parsing.complex"> @@ -1077,6 +1078,7 @@ functions <function>print_r</function> and <function>var_dump</function> for better ways to print out values for debugging. </para> + <para> You can also convert PHP values to strings to store them permanently. This method is called serialization, and can be done with the function