cvs: phpdoc /ja/language types.xml
| From: | Masaki Fujimoto | Date: | Thu, 13 Dec 2001 14:43:21 +0000 |
| Subject: | cvs: phpdoc /ja/language types.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969339702@lists.php.net to get a copy of this message | ||
fujimoto Thu Dec 13 09:43:21 2001 EDT
Modified files:
/phpdoc/ja/language types.xml
Log:
updated translation.
Index: phpdoc/ja/language/types.xml diff -u phpdoc/ja/language/types.xml:1.14 phpdoc/ja/language/types.xml:1.15 --- phpdoc/ja/language/types.xml:1.14 Wed Dec 12 15:54:03 2001 +++ phpdoc/ja/language/types.xml Thu Dec 13 09:43:21 2001 @@ -100,6 +100,20 @@ 夿°ã®åã¯ãä¸è¬ã«ããã°ã©ãã«ããã»ããããã¾ããããããããã®å¤ æ°ã使ç¨ãããæã®å 容ã«å¿ã㦠PHP ã«ããå®è¡æã«æ±ºå®ããã¾ãã </simpara> + <tip> + <simpara> + ãã<link linkend="language.expressions">å¼</link>ã®åã¨å¤ãæ£ç¢ºã« + ç¥ãããå ´åã¯ã<function>var_dump</function>颿°ã使ç¨ãã¦ãã ããã + </simpara> + <simpara> + åç´ã«ãããã°ã®ããã«äººéãèªã¿ãããå½¢ã§åã表示ãããå ´åã«ã¯ + <function>gettype</function>ã使ç¨ãã¦ãã ãããåããã§ãã¯ãã + å ´åã«ã¯<function>gettype</function>ã使ç¨ãã¦ã¯<emphasis>ããã¾ãã + </emphasis>ã<literal>is_<replaceable>type</replaceable></literal> + 颿°ã使ç¨ãã¦ãã ããã + </simpara> + <!-- TODO: example(s) would be great --> + </tip> <simpara> ãã夿°ã®åãå¼·å¶çã«ä»ã®åã«å¤æãããå ´åã夿°ã <link linkend="language.types.typecasting">ãã£ã¹ã</link> ãããã @@ -137,7 +151,9 @@ <!-- technically they are just constants --> <informalexample> <programlisting role="php"> +<![CDATA[ $foo = True; // å¤TRUEã$fooã«ä»£å ¥ãã +]]> </programlisting> </informalexample> </para> @@ -147,6 +163,7 @@ <link linkend="control-structures">å¶å¾¡æ§é </link>ã«ãã®çµæã渡 ãã¾ãã <informalexample> + <!-- intentionally omitting CDATA --> <programlisting role="php"> if ($action == "show_version") // == ã¯ã<type>boolean</type>åãè¿ã // <link linkend="language.operators">æ¼ç®å</link> @@ -229,7 +246,8 @@ </listitem> <listitem> <simpara> - ç¹å¥ãªå¤ <link linkend="language.types.null">&null;</link> + ç¹å¥ãªå¤ <link linkend="language.types.null">NULL</link> (å¤ãã»ãã + ããã¦ããªã夿°ãå«ã) </simpara> </listitem> </itemizedlist> @@ -260,7 +278,7 @@ <para> <link linkend="ref.gmp">ä»»æç²¾åº¦æ´æ°</link> ããã³ - <link linkend="language.types.float">double</link>ãåç §ä¸ããã + <link linkend="language.types.float">float</link>ãåç §ä¸ããã </para> <sect2 id="language.types.integer.syntax"> @@ -277,10 +295,12 @@ <example> <title>æ´æ°ãªãã©ã«</title> <programlisting role="php"> +<![CDATA[ $a = 1234; # 10鲿´æ° $a = -123; # è² ã®æ° $a = 0123; # 18鲿° (10鲿°ã®83ã¨ç価) $a = 0x1A; # 16鲿° (10鲿°ã®26ã¨ç価) +]]> </programlisting> </example> <!-- @@ -300,57 +320,64 @@ æå¤§å¤ãç´20åã§ãã(32ããã符å·ä»)ã¨ããã®ãä¸è¬çãªå¤ã§ããã æ´æ°ã®ãµã¤ãºã¯ãã©ãããã©ã¼ã ä¾åã§ãã </para> - <note><!-- or warning? --> - <simpara> - PHPã§ã¯ãæ´æ°ã®å²ç®ã¯ããã¾ããã<literal>1/2</literal>ã¯ã - <type>double</type>åã®<literal>0.5</literal>ã«ãªãã¾ãã - <!-- See ??? for more information. (with the operators, or with - type-jug) --> - </simpara> - </note> </sect2> <sect2 id="language.types.integer.overflow"> <title>æ´æ°ã®ãªã¼ãã¼ããã¼</title> <para> <type>integer</type>åã®ç¯å²å¤ã®æ°ãæå®ããå ´åããããã« - <type>double</type>ã¨ãã¦è§£éããã¾ãã + <type>float</type>ã¨ãã¦è§£éããã¾ããã¾ããçµæã<type> + integer</type>åã®ç¯å²å¤ã®æ°ã¨ãªããããªè¨ç®ãè¡ãã¨<type> + float</type>ã代ããã«è¿ããã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ $large_number = 2147483647; var_dump($large_number); // åºå: int(2147483647) + $large_number = 2147483648; var_dump($large_number); // åºå: float(2147483648) // æå®ãã16é²è¡¨ç¾æ´æ°ãåºå - var_dump( 0x80000000 ); // åºå: float(2147483648) - </programlisting> - </informalexample> - æ´ã«ã颿°ã¾ãã¯æ¼ç®åãã<type>integer</type>ã®ç¯å²å¤ã®æ°ãçæ - ããå ´åãèªåçã«<type>float</type>ã«å¤æããã¾ãã - <informalexample> - <programlisting role="php"> + $million = 1000000; $large_number = 50000 * $million; var_dump($large_number); // åºå: float(50000000000) +]]> </programlisting> </informalexample> <warning> <simpara> - ä¸å¹¸ã«ãã¦ãã¹ã¯ãªããã¨ã³ã¸ã³ã«ã¯ãã°(4.0.6ã«ã¯ã¾ã ãããæãã - 4.0.7ã§ã¯è§£æ±ºãããã§ããã)ããããè² ã®æ°ãå«ã¾ãã¦ããå ´åã«ã + ä¸å¹¸ã«ãã¦ãã¹ã¯ãªããã¨ã³ã¸ã³ã«ã¯ãã°ãããã + è² ã®æ°ãå«ã¾ãã¦ããå ´åã«ã å¸¸ã«æ£ããåä½ããããã§ã¯ããã¾ãããä¾ãã°ã <literal>-50000 * $million</literal>ãå®è¡ããå ´åãçµæã¯ã <literal>-429496728</literal>ã¨ãªãã¾ãããããããªãã©ã³ããå ±ã« æ£ã®å ´åã¯åé¡ããã¾ããã </simpara> + <simpara> + ãã®åé¡ã¯PHP 4.1.0ã§è§£æ±ºããã¾ããã + </simpara> </warning> </para> + <para> + PHPã«ã¯æ´æ°ã®å²ãç®ã¯ããã¾ããã<literal>1/2</literal>ã¯<type> + float</type>åã®0.5ã«ãªãã¾ãã<!-- See ??? for more information. + (with the operators, or with type-jug) --> + <informalexample> + <programlisting role="php"> +<![CDATA[ +var_dump( 25/7 ); +// output: float(3.5714285714286) +]]> + </programlisting> + </informalexample> + </para> </sect2> <sect2 id="language.types.integer.casting"> @@ -398,7 +425,9 @@ å ´åãäºæããªãçµæã¨ãªããã¨ãããã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ echo (int) ( (0.1+0.7) * 10 ); // 7ãåºåããã¾ã! +]]> </programlisting> </informalexample> ããè©³ç´°ãªæ å ±ã«ã¤ãã¦ã¯ã<link linkend="warn.float-precision"> @@ -553,6 +582,7 @@ </note> <informalexample> <programlisting role="php"> +<![CDATA[ echo 'this is a simple string'; echo 'You can also have embedded newlines in strings, like this way.'; @@ -564,6 +594,7 @@ // åºå: ... delete C:\*.*? echo 'I am trying to include at this point: \n a newline'; // åºå: ... this point: \n a newline +]]> </programlisting> </informalexample> </para> @@ -682,16 +713,18 @@ ã«ã¯æ³¨æãå¿ è¦ã§ãã <example> <title>ãã¢ããã¥ã¡ã³ãã§æååãæ¬ãä¾</title> - <programlisting> -<?php -$str = <<<EOD + <programlisting role="php"> +<![CDATA[ +<?php +$str = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; /* 夿°ã使ç¨ããããè¤éãªä¾ */ -class foo { +class foo +{ var $foo; var $bar; @@ -704,12 +737,13 @@ $foo = new foo(); $name = 'MyName'; -echo <<<EOT +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 EOT; ?> +]]> </programlisting> </example> </para> @@ -750,10 +784,12 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ $beer = 'Heineken'; echo "$beer's taste is great"; // åä½ãã¾ãã"'" ã¯å¤æ°åã¨ãã¦ç¡å¹ãªæåã§ãã echo "He drunk some $beers"; // åä½ãã¾ããã's' ã¯ã夿°åã¨ãã¦æå¹ãªæåã§ãã echo "He drunk some ${beer}s"; // åä½ãã¾ãã +]]> </programlisting> </informalexample> <simpara> @@ -772,9 +808,11 @@ </simpara> <informalexample> + <!-- intentionally omitting CDATA --> <programlisting role="php"> $fruits = array( 'strawberry' => 'red' , 'banana' => 'yellow' ); -echo "A banana is $fruits[banana]."; +echo "A banana is $fruits[banana]."; // ã·ã³ã°ã«ã¯ãªã¼ãã®å¤ã§ã¯åä½ãç°ãªããã¨ã«æ³¨æãã¦ãã ããã + // <link linkend="language.types.array.foo-bar"><literal>$foo[bar]</literal></link>ãåç §ãã¦ãã ããã echo "This square is $square->width meters broad."; echo "This square is $square->width00 centimeters broad."; // åä½ãã¾ããã // 解決çã«ã¤ãã¦ã¯ã<link linkend="language.types.string.parsing.complex">è¤éãªæ§æ</link>ãåç §ä¸ããã @@ -845,10 +883,11 @@ <example> <title>è¤æ°ã®stringã®ä¾</title> <programlisting role="php"> +<![CDATA[ <!-- TODO: either move these examples to a example section, as with arrays, or distribute them under the applicable sections. --> -<?php +<?php /* æååã«ä»£å ¥ã */ $str = "This is a string"; @@ -858,13 +897,13 @@ /* 追å ããå¥ã®æ¹æ³ãæ¹è¡ã示ãã¨ã¹ã±ã¼ãæåãå«ãã */ $str .= " and a newline at the end.\n"; -/* ãã®æååã¯ãæçµçã«'<p>Number: 9</p>'ã¨ãªãã¾ã */ +/* ãã®æååã¯ãæçµçã«'<p>Number: 9</p>'ã¨ãªãã¾ã */ $num = 9; -$str = "<p>Number: $num</p>"; +$str = "<p>Number: $num</p>"; -/* ãã®æååã¯ã'<p>Number: $num</p>'ã¨ãªãã¾ãã */ +/* ãã®æååã¯ã'<p>Number: $num</p>'ã¨ãªãã¾ãã */ $num = 9; -$str = '<p>Number: $num</p>'; +$str = '<p>Number: $num</p>'; /* æååã®æåã®æåãå¾ã */ $str = 'This is a test.'; @@ -873,7 +912,8 @@ /* æååã®æå¾ã®æåãå¾ã */ $str = 'This is still a test.'; $last = $str{strlen($str)-1}; -?> +?> +]]> </programlisting> </example> </para> @@ -934,6 +974,7 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ $foo = 1 + "10.5"; // $foo 㯠float ã§ã (11.5) $foo = 1 + "-1.3e3"; // $foo 㯠float ã§ã (-1299) $foo = 1 + "bob-1.3e3"; // $foo 㯠integer ã§ã (1) @@ -942,6 +983,7 @@ $foo = 1 + "10 Little Piggies"; // $foo 㯠integer ã§ã (11) $foo = "10.0 pigs " + 1; // $foo 㯠integer ã§ã (11) $foo = "10.0 pigs " + 1.0; // $foo 㯠float ã§ã (11) +]]> </programlisting> </informalexample> <simpara> @@ -952,7 +994,9 @@ åä½ã確èªããããã«æ¬¡ã®è¡ãæ¿å ¥ãã¦ä¸ããã <informalexample> <programlisting role="php"> -echo "\$foo==$foo; type is " . gettype ($foo) . "<br>\n"; +<![CDATA[ +echo "\$foo==$foo; type is " . gettype ($foo) . "<br>\n"; +]]> </programlisting> </informalexample> </para> @@ -1080,6 +1124,26 @@ é åã§ä½¿ç¨ãã便å©ãªé¢æ°ãããããããã¾ãã <link linkend="ref.array">é å颿°</link> ã®ç¯ãåç §ä¸ããã </para> + <note> + <para> + <function>unset</function>颿°ã¯é åã®ãã¼ãåé¤ãããã¨ãåºæ¥ã¾ãã + ãã ããããã«ãã£ã¦ã¤ã³ããã¯ã¹ã®åæ§ç¯ãè¡ãããããã§ã¯<emphasis> + ãªã</emphasis>ã¨ãããã¨ã«æ°ãã¤ãã¦ãã ããã + <informalexample> + <programlisting role="php"> +<![CDATA[ +$a = array( 1 => 'one', 2 => 'two', 3 => 'three' ); +unset( $a[2] ); +/* ããã«ããé åã¯ä»¥ä¸ã®æ§ã«å®ç¾©ããã¾ãã + $a = array( 1=>'one', 3=>'three'); + ããã§ã¯ããã¾ããï¼ + $a = array( 1 => 'one', 2 => 'three'); +*/ +]]> + </programlisting> + </informalexample> + </para> + </note> <para> å¶å¾¡æ§é <link linkend="control-structures.foreach">foreach</link> ãé åç¨ã«éå®ãã¦åå¨ãã¾ãããã®æ§é ã¯ãé åã®è¦ç´ ã«ç°¡åã«é£ç¶ @@ -1096,9 +1160,11 @@ å¤ãã¹ã¯ãªããã§æ¬¡ã®ãããªæ§æãè¦ããã¨ãããããããã¾ããã <informalexample> <programlisting role="php"> +<![CDATA[ $foo[bar] = 'enemy'; echo $foo[bar]; // ç +]]> </programlisting> </informalexample> ããã¯ééã£ã¦ãã¾ãããåä½ãã¾ããã§ã¯ããªãééã£ã¦ããã®ã§ãã @@ -1109,7 +1175,9 @@ æå³ãã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ echo $arr[ foo(true) ]; +]]> </programlisting> </informalexample> ããã¯ã颿°ã®åºåãé åã®æ·»åã¨ãã¦ä½¿ç¨ããä¾ã§ããPHPã¯å®æ°ã« @@ -1118,9 +1186,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $error_descriptions[E_ERROR] = "A fatal error has occured"; $error_descriptions[E_WARNING] = "PHP issued a warning"; $error_descriptions[E_NOTICE] = "This is just an informal notice"; +]]> </programlisting> </informalexample> æåã®ä¾ã®<literal>bar</literal>ã¨å ¨ãåæ§ã« @@ -1128,9 +1198,11 @@ ããããããå®éã«ã¯æå¾ã®ä¾ã¯æ¬¡ã®ããã«æ¸ããã¨ã¨åãã§ãã <informalexample> <programlisting role="php"> +<![CDATA[ $error_descriptions[1] = "A fatal error has occured"; $error_descriptions[2] = "PHP issued a warning"; $error_descriptions[8] = "This is just an informal notice"; +]]> </programlisting> </informalexample> ããã¯ã<literal>E_ERROR</literal> ã <literal>1</literal>ã¨çã @@ -1194,6 +1266,7 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ // this $a = array( 'color' => 'red' , 'taste' => 'sweet' @@ -1214,6 +1287,7 @@ $b[] = 'c'; // ãã®çµæã¯é å array( 0 => 'a' , 1 => 'b' , 2 => 'c' ) // ã¾ãã¯åã« array('a', 'b', 'c') ã¨ãªãã¾ã +]]> </programlisting> </informalexample> </para> @@ -1221,11 +1295,12 @@ <example> <title>array()ã®ä½¿ç¨ä¾</title> <programlisting role="php"> +<![CDATA[ // ããããè¡ãé å -$map = array( 'version' => 4 - , 'OS' => 'Linux' - , 'lang' => 'english' - , 'short_tags' => true +$map = array( 'version' => 4 + , 'OS' => 'Linux' + , 'lang' => 'english' + , 'short_tags' => true ); // æ°å¤ãã¼ã®ã¿ãæãã @@ -1235,16 +1310,16 @@ , 156 , -10 ); -// ããã¯ãarray( 0 => 7, 1 => 8, ...) ã¨åãã§ã +// ããã¯ãarray( 0 => 7, 1 => 8, ...) ã¨åãã§ã $switching = array( 10 // key = 0 - , 5 => 6 - , 3 => 7 - , 'a' => 4 + , 5 => 6 + , 3 => 7 + , 'a' => 4 , 11 // key = 6 (æå¤§ã®æ·»åã¯5ã§ã) - , '8' => 2 // key = 8 (æ´æ°!) - , '02' => 77 // key = '02' - , 0 => 12 // å¤10ã¯12ã§ä¸æ¸ãããã¾ã + , '8' => 2 // key = 8 (æ´æ°!) + , '02' => 77 // key = '02' + , 0 => 12 // å¤10ã¯12ã§ä¸æ¸ãããã¾ã ); <!-- TODO example of @@ -1257,16 +1332,17 @@ // empty array $empty = array(); +]]> </programlisting> </example> <example id="language.types.array.examples.loop"> <title>ã³ã¬ã¯ã·ã§ã³</title> <programlisting role="php"> +<![CDATA[ $colors = array('red','blue','green','yellow'); -foreach ( $colors as $color ) -{ +foreach ( $colors as $color ) { echo "Do you like $color?\n"; } @@ -1276,6 +1352,7 @@ Do you like green? Do you like yellow? */ +]]> </programlisting> </example> @@ -1292,8 +1369,7 @@ <example id="language.types.array.examples.changeloop"> <title>ã³ã¬ã¯ã·ã§ã³</title> <programlisting role="php"> -<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color ) -{ +<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color ) { // åä½ããªã: //$color = <link linkend="function.strtoupper">strtoupper</link>($color); @@ -1338,7 +1414,7 @@ <programlisting role="php"> // <link linkend="ref.dir">ãã£ã¬ã¯ããª</link>ããå ¨ã¦ã®ã¢ã¤ãã ãé åã«ä»£å ¥ãã $handle = <link linkend="function.opendir">opendir</link>('.'); -while ( $file = <link linkend="function.readdir">readdir</link>($handle) ) +while ($file = <link linkend="function.readdir">readdir</link>($handle)) { $files[] = $file; } @@ -1601,8 +1677,10 @@ <informalexample> <programlisting role="php"> <?php -class foo { - function do_foo () { +class foo +{ + function do_foo() + { echo "Doing foo."; } } @@ -1683,7 +1761,7 @@ &null;ã§ãã <informalexample> <programlisting role="php"> -$var = Null; +$var = NULL; </programlisting> </informalexample> </para>
Index: phpdoc/ja/language/types.xml diff -u phpdoc/ja/language/types.xml:1.14 phpdoc/ja/language/types.xml:1.15 --- phpdoc/ja/language/types.xml:1.14 Wed Dec 12 15:54:03 2001 +++ phpdoc/ja/language/types.xml Thu Dec 13 09:43:21 2001 @@ -100,6 +100,20 @@ 夿°ã®åã¯ãä¸è¬ã«ããã°ã©ãã«ããã»ããããã¾ããããããããã®å¤ æ°ã使ç¨ãããæã®å 容ã«å¿ã㦠PHP ã«ããå®è¡æã«æ±ºå®ããã¾ãã </simpara> + <tip> + <simpara> + ãã<link linkend="language.expressions">å¼</link>ã®åã¨å¤ãæ£ç¢ºã« + ç¥ãããå ´åã¯ã<function>var_dump</function>颿°ã使ç¨ãã¦ãã ããã + </simpara> + <simpara> + åç´ã«ãããã°ã®ããã«äººéãèªã¿ãããå½¢ã§åã表示ãããå ´åã«ã¯ + <function>gettype</function>ã使ç¨ãã¦ãã ãããåããã§ãã¯ãã + å ´åã«ã¯<function>gettype</function>ã使ç¨ãã¦ã¯<emphasis>ããã¾ãã + </emphasis>ã<literal>is_<replaceable>type</replaceable></literal> + 颿°ã使ç¨ãã¦ãã ããã + </simpara> + <!-- TODO: example(s) would be great --> + </tip> <simpara> ãã夿°ã®åãå¼·å¶çã«ä»ã®åã«å¤æãããå ´åã夿°ã <link linkend="language.types.typecasting">ãã£ã¹ã</link> ãããã @@ -137,7 +151,9 @@ <!-- technically they are just constants --> <informalexample> <programlisting role="php"> +<![CDATA[ $foo = True; // å¤TRUEã$fooã«ä»£å ¥ãã +]]> </programlisting> </informalexample> </para> @@ -147,6 +163,7 @@ <link linkend="control-structures">å¶å¾¡æ§é </link>ã«ãã®çµæã渡 ãã¾ãã <informalexample> + <!-- intentionally omitting CDATA --> <programlisting role="php"> if ($action == "show_version") // == ã¯ã<type>boolean</type>åãè¿ã // <link linkend="language.operators">æ¼ç®å</link> @@ -229,7 +246,8 @@ </listitem> <listitem> <simpara> - ç¹å¥ãªå¤ <link linkend="language.types.null">&null;</link> + ç¹å¥ãªå¤ <link linkend="language.types.null">NULL</link> (å¤ãã»ãã + ããã¦ããªã夿°ãå«ã) </simpara> </listitem> </itemizedlist> @@ -260,7 +278,7 @@ <para> <link linkend="ref.gmp">ä»»æç²¾åº¦æ´æ°</link> ããã³ - <link linkend="language.types.float">double</link>ãåç §ä¸ããã + <link linkend="language.types.float">float</link>ãåç §ä¸ããã </para> <sect2 id="language.types.integer.syntax"> @@ -277,10 +295,12 @@ <example> <title>æ´æ°ãªãã©ã«</title> <programlisting role="php"> +<![CDATA[ $a = 1234; # 10鲿´æ° $a = -123; # è² ã®æ° $a = 0123; # 18鲿° (10鲿°ã®83ã¨ç価) $a = 0x1A; # 16鲿° (10鲿°ã®26ã¨ç価) +]]> </programlisting> </example> <!-- @@ -300,57 +320,64 @@ æå¤§å¤ãç´20åã§ãã(32ããã符å·ä»)ã¨ããã®ãä¸è¬çãªå¤ã§ããã æ´æ°ã®ãµã¤ãºã¯ãã©ãããã©ã¼ã ä¾åã§ãã </para> - <note><!-- or warning? --> - <simpara> - PHPã§ã¯ãæ´æ°ã®å²ç®ã¯ããã¾ããã<literal>1/2</literal>ã¯ã - <type>double</type>åã®<literal>0.5</literal>ã«ãªãã¾ãã - <!-- See ??? for more information. (with the operators, or with - type-jug) --> - </simpara> - </note> </sect2> <sect2 id="language.types.integer.overflow"> <title>æ´æ°ã®ãªã¼ãã¼ããã¼</title> <para> <type>integer</type>åã®ç¯å²å¤ã®æ°ãæå®ããå ´åããããã« - <type>double</type>ã¨ãã¦è§£éããã¾ãã + <type>float</type>ã¨ãã¦è§£éããã¾ããã¾ããçµæã<type> + integer</type>åã®ç¯å²å¤ã®æ°ã¨ãªããããªè¨ç®ãè¡ãã¨<type> + float</type>ã代ããã«è¿ããã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ $large_number = 2147483647; var_dump($large_number); // åºå: int(2147483647) + $large_number = 2147483648; var_dump($large_number); // åºå: float(2147483648) // æå®ãã16é²è¡¨ç¾æ´æ°ãåºå - var_dump( 0x80000000 ); // åºå: float(2147483648) - </programlisting> - </informalexample> - æ´ã«ã颿°ã¾ãã¯æ¼ç®åãã<type>integer</type>ã®ç¯å²å¤ã®æ°ãçæ - ããå ´åãèªåçã«<type>float</type>ã«å¤æããã¾ãã - <informalexample> - <programlisting role="php"> + $million = 1000000; $large_number = 50000 * $million; var_dump($large_number); // åºå: float(50000000000) +]]> </programlisting> </informalexample> <warning> <simpara> - ä¸å¹¸ã«ãã¦ãã¹ã¯ãªããã¨ã³ã¸ã³ã«ã¯ãã°(4.0.6ã«ã¯ã¾ã ãããæãã - 4.0.7ã§ã¯è§£æ±ºãããã§ããã)ããããè² ã®æ°ãå«ã¾ãã¦ããå ´åã«ã + ä¸å¹¸ã«ãã¦ãã¹ã¯ãªããã¨ã³ã¸ã³ã«ã¯ãã°ãããã + è² ã®æ°ãå«ã¾ãã¦ããå ´åã«ã å¸¸ã«æ£ããåä½ããããã§ã¯ããã¾ãããä¾ãã°ã <literal>-50000 * $million</literal>ãå®è¡ããå ´åãçµæã¯ã <literal>-429496728</literal>ã¨ãªãã¾ãããããããªãã©ã³ããå ±ã« æ£ã®å ´åã¯åé¡ããã¾ããã </simpara> + <simpara> + ãã®åé¡ã¯PHP 4.1.0ã§è§£æ±ºããã¾ããã + </simpara> </warning> </para> + <para> + PHPã«ã¯æ´æ°ã®å²ãç®ã¯ããã¾ããã<literal>1/2</literal>ã¯<type> + float</type>åã®0.5ã«ãªãã¾ãã<!-- See ??? for more information. + (with the operators, or with type-jug) --> + <informalexample> + <programlisting role="php"> +<![CDATA[ +var_dump( 25/7 ); +// output: float(3.5714285714286) +]]> + </programlisting> + </informalexample> + </para> </sect2> <sect2 id="language.types.integer.casting"> @@ -398,7 +425,9 @@ å ´åãäºæããªãçµæã¨ãªããã¨ãããã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ echo (int) ( (0.1+0.7) * 10 ); // 7ãåºåããã¾ã! +]]> </programlisting> </informalexample> ããè©³ç´°ãªæ å ±ã«ã¤ãã¦ã¯ã<link linkend="warn.float-precision"> @@ -553,6 +582,7 @@ </note> <informalexample> <programlisting role="php"> +<![CDATA[ echo 'this is a simple string'; echo 'You can also have embedded newlines in strings, like this way.'; @@ -564,6 +594,7 @@ // åºå: ... delete C:\*.*? echo 'I am trying to include at this point: \n a newline'; // åºå: ... this point: \n a newline +]]> </programlisting> </informalexample> </para> @@ -682,16 +713,18 @@ ã«ã¯æ³¨æãå¿ è¦ã§ãã <example> <title>ãã¢ããã¥ã¡ã³ãã§æååãæ¬ãä¾</title> - <programlisting> -<?php -$str = <<<EOD + <programlisting role="php"> +<![CDATA[ +<?php +$str = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; /* 夿°ã使ç¨ããããè¤éãªä¾ */ -class foo { +class foo +{ var $foo; var $bar; @@ -704,12 +737,13 @@ $foo = new foo(); $name = 'MyName'; -echo <<<EOT +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 EOT; ?> +]]> </programlisting> </example> </para> @@ -750,10 +784,12 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ $beer = 'Heineken'; echo "$beer's taste is great"; // åä½ãã¾ãã"'" ã¯å¤æ°åã¨ãã¦ç¡å¹ãªæåã§ãã echo "He drunk some $beers"; // åä½ãã¾ããã's' ã¯ã夿°åã¨ãã¦æå¹ãªæåã§ãã echo "He drunk some ${beer}s"; // åä½ãã¾ãã +]]> </programlisting> </informalexample> <simpara> @@ -772,9 +808,11 @@ </simpara> <informalexample> + <!-- intentionally omitting CDATA --> <programlisting role="php"> $fruits = array( 'strawberry' => 'red' , 'banana' => 'yellow' ); -echo "A banana is $fruits[banana]."; +echo "A banana is $fruits[banana]."; // ã·ã³ã°ã«ã¯ãªã¼ãã®å¤ã§ã¯åä½ãç°ãªããã¨ã«æ³¨æãã¦ãã ããã + // <link linkend="language.types.array.foo-bar"><literal>$foo[bar]</literal></link>ãåç §ãã¦ãã ããã echo "This square is $square->width meters broad."; echo "This square is $square->width00 centimeters broad."; // åä½ãã¾ããã // 解決çã«ã¤ãã¦ã¯ã<link linkend="language.types.string.parsing.complex">è¤éãªæ§æ</link>ãåç §ä¸ããã @@ -845,10 +883,11 @@ <example> <title>è¤æ°ã®stringã®ä¾</title> <programlisting role="php"> +<![CDATA[ <!-- TODO: either move these examples to a example section, as with arrays, or distribute them under the applicable sections. --> -<?php +<?php /* æååã«ä»£å ¥ã */ $str = "This is a string"; @@ -858,13 +897,13 @@ /* 追å ããå¥ã®æ¹æ³ãæ¹è¡ã示ãã¨ã¹ã±ã¼ãæåãå«ãã */ $str .= " and a newline at the end.\n"; -/* ãã®æååã¯ãæçµçã«'<p>Number: 9</p>'ã¨ãªãã¾ã */ +/* ãã®æååã¯ãæçµçã«'<p>Number: 9</p>'ã¨ãªãã¾ã */ $num = 9; -$str = "<p>Number: $num</p>"; +$str = "<p>Number: $num</p>"; -/* ãã®æååã¯ã'<p>Number: $num</p>'ã¨ãªãã¾ãã */ +/* ãã®æååã¯ã'<p>Number: $num</p>'ã¨ãªãã¾ãã */ $num = 9; -$str = '<p>Number: $num</p>'; +$str = '<p>Number: $num</p>'; /* æååã®æåã®æåãå¾ã */ $str = 'This is a test.'; @@ -873,7 +912,8 @@ /* æååã®æå¾ã®æåãå¾ã */ $str = 'This is still a test.'; $last = $str{strlen($str)-1}; -?> +?> +]]> </programlisting> </example> </para> @@ -934,6 +974,7 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ $foo = 1 + "10.5"; // $foo 㯠float ã§ã (11.5) $foo = 1 + "-1.3e3"; // $foo 㯠float ã§ã (-1299) $foo = 1 + "bob-1.3e3"; // $foo 㯠integer ã§ã (1) @@ -942,6 +983,7 @@ $foo = 1 + "10 Little Piggies"; // $foo 㯠integer ã§ã (11) $foo = "10.0 pigs " + 1; // $foo 㯠integer ã§ã (11) $foo = "10.0 pigs " + 1.0; // $foo 㯠float ã§ã (11) +]]> </programlisting> </informalexample> <simpara> @@ -952,7 +994,9 @@ åä½ã確èªããããã«æ¬¡ã®è¡ãæ¿å ¥ãã¦ä¸ããã <informalexample> <programlisting role="php"> -echo "\$foo==$foo; type is " . gettype ($foo) . "<br>\n"; +<![CDATA[ +echo "\$foo==$foo; type is " . gettype ($foo) . "<br>\n"; +]]> </programlisting> </informalexample> </para> @@ -1080,6 +1124,26 @@ é åã§ä½¿ç¨ãã便å©ãªé¢æ°ãããããããã¾ãã <link linkend="ref.array">é å颿°</link> ã®ç¯ãåç §ä¸ããã </para> + <note> + <para> + <function>unset</function>颿°ã¯é åã®ãã¼ãåé¤ãããã¨ãåºæ¥ã¾ãã + ãã ããããã«ãã£ã¦ã¤ã³ããã¯ã¹ã®åæ§ç¯ãè¡ãããããã§ã¯<emphasis> + ãªã</emphasis>ã¨ãããã¨ã«æ°ãã¤ãã¦ãã ããã + <informalexample> + <programlisting role="php"> +<![CDATA[ +$a = array( 1 => 'one', 2 => 'two', 3 => 'three' ); +unset( $a[2] ); +/* ããã«ããé åã¯ä»¥ä¸ã®æ§ã«å®ç¾©ããã¾ãã + $a = array( 1=>'one', 3=>'three'); + ããã§ã¯ããã¾ããï¼ + $a = array( 1 => 'one', 2 => 'three'); +*/ +]]> + </programlisting> + </informalexample> + </para> + </note> <para> å¶å¾¡æ§é <link linkend="control-structures.foreach">foreach</link> ãé åç¨ã«éå®ãã¦åå¨ãã¾ãããã®æ§é ã¯ãé åã®è¦ç´ ã«ç°¡åã«é£ç¶ @@ -1096,9 +1160,11 @@ å¤ãã¹ã¯ãªããã§æ¬¡ã®ãããªæ§æãè¦ããã¨ãããããããã¾ããã <informalexample> <programlisting role="php"> +<![CDATA[ $foo[bar] = 'enemy'; echo $foo[bar]; // ç +]]> </programlisting> </informalexample> ããã¯ééã£ã¦ãã¾ãããåä½ãã¾ããã§ã¯ããªãééã£ã¦ããã®ã§ãã @@ -1109,7 +1175,9 @@ æå³ãã¾ãã <informalexample> <programlisting role="php"> +<![CDATA[ echo $arr[ foo(true) ]; +]]> </programlisting> </informalexample> ããã¯ã颿°ã®åºåãé åã®æ·»åã¨ãã¦ä½¿ç¨ããä¾ã§ããPHPã¯å®æ°ã« @@ -1118,9 +1186,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $error_descriptions[E_ERROR] = "A fatal error has occured"; $error_descriptions[E_WARNING] = "PHP issued a warning"; $error_descriptions[E_NOTICE] = "This is just an informal notice"; +]]> </programlisting> </informalexample> æåã®ä¾ã®<literal>bar</literal>ã¨å ¨ãåæ§ã« @@ -1128,9 +1198,11 @@ ããããããå®éã«ã¯æå¾ã®ä¾ã¯æ¬¡ã®ããã«æ¸ããã¨ã¨åãã§ãã <informalexample> <programlisting role="php"> +<![CDATA[ $error_descriptions[1] = "A fatal error has occured"; $error_descriptions[2] = "PHP issued a warning"; $error_descriptions[8] = "This is just an informal notice"; +]]> </programlisting> </informalexample> ããã¯ã<literal>E_ERROR</literal> ã <literal>1</literal>ã¨çã @@ -1194,6 +1266,7 @@ <para> <informalexample> <programlisting role="php"> +<![CDATA[ // this $a = array( 'color' => 'red' , 'taste' => 'sweet' @@ -1214,6 +1287,7 @@ $b[] = 'c'; // ãã®çµæã¯é å array( 0 => 'a' , 1 => 'b' , 2 => 'c' ) // ã¾ãã¯åã« array('a', 'b', 'c') ã¨ãªãã¾ã +]]> </programlisting> </informalexample> </para> @@ -1221,11 +1295,12 @@ <example> <title>array()ã®ä½¿ç¨ä¾</title> <programlisting role="php"> +<![CDATA[ // ããããè¡ãé å -$map = array( 'version' => 4 - , 'OS' => 'Linux' - , 'lang' => 'english' - , 'short_tags' => true +$map = array( 'version' => 4 + , 'OS' => 'Linux' + , 'lang' => 'english' + , 'short_tags' => true ); // æ°å¤ãã¼ã®ã¿ãæãã @@ -1235,16 +1310,16 @@ , 156 , -10 ); -// ããã¯ãarray( 0 => 7, 1 => 8, ...) ã¨åãã§ã +// ããã¯ãarray( 0 => 7, 1 => 8, ...) ã¨åãã§ã $switching = array( 10 // key = 0 - , 5 => 6 - , 3 => 7 - , 'a' => 4 + , 5 => 6 + , 3 => 7 + , 'a' => 4 , 11 // key = 6 (æå¤§ã®æ·»åã¯5ã§ã) - , '8' => 2 // key = 8 (æ´æ°!) - , '02' => 77 // key = '02' - , 0 => 12 // å¤10ã¯12ã§ä¸æ¸ãããã¾ã + , '8' => 2 // key = 8 (æ´æ°!) + , '02' => 77 // key = '02' + , 0 => 12 // å¤10ã¯12ã§ä¸æ¸ãããã¾ã ); <!-- TODO example of @@ -1257,16 +1332,17 @@ // empty array $empty = array(); +]]> </programlisting> </example> <example id="language.types.array.examples.loop"> <title>ã³ã¬ã¯ã·ã§ã³</title> <programlisting role="php"> +<![CDATA[ $colors = array('red','blue','green','yellow'); -foreach ( $colors as $color ) -{ +foreach ( $colors as $color ) { echo "Do you like $color?\n"; } @@ -1276,6 +1352,7 @@ Do you like green? Do you like yellow? */ +]]> </programlisting> </example> @@ -1292,8 +1369,7 @@ <example id="language.types.array.examples.changeloop"> <title>ã³ã¬ã¯ã·ã§ã³</title> <programlisting role="php"> -<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color ) -{ +<link linkend="control-structures.foreach">foreach</link> ( $colors as $key => $color ) { // åä½ããªã: //$color = <link linkend="function.strtoupper">strtoupper</link>($color); @@ -1338,7 +1414,7 @@ <programlisting role="php"> // <link linkend="ref.dir">ãã£ã¬ã¯ããª</link>ããå ¨ã¦ã®ã¢ã¤ãã ãé åã«ä»£å ¥ãã $handle = <link linkend="function.opendir">opendir</link>('.'); -while ( $file = <link linkend="function.readdir">readdir</link>($handle) ) +while ($file = <link linkend="function.readdir">readdir</link>($handle)) { $files[] = $file; } @@ -1601,8 +1677,10 @@ <informalexample> <programlisting role="php"> <?php -class foo { - function do_foo () { +class foo +{ + function do_foo() + { echo "Doing foo."; } } @@ -1683,7 +1761,7 @@ &null;ã§ãã <informalexample> <programlisting role="php"> -$var = Null; +$var = NULL; </programlisting> </informalexample> </para>