cvs: phpdoc /ja/language functions.xml oop.xml
| From: | Masaki Fujimoto | Date: | Sun, 16 Dec 2001 10:04:35 +0000 |
| Subject: | cvs: phpdoc /ja/language functions.xml oop.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969339853@lists.php.net to get a copy of this message | ||
fujimoto Sun Dec 16 05:04:35 2001 EDT
Modified files:
/phpdoc/ja/language functions.xml oop.xml
Log:
updated translation.
Index: phpdoc/ja/language/functions.xml diff -u phpdoc/ja/language/functions.xml:1.8 phpdoc/ja/language/functions.xml:1.9 --- phpdoc/ja/language/functions.xml:1.8 Wed Dec 12 15:54:00 2001 +++ phpdoc/ja/language/functions.xml Sun Dec 16 05:04:35 2001 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.9 $ --> <chapter id="functions"> <title>颿°</title> @@ -10,10 +11,13 @@ <informalexample> <programlisting role="php"> -function foo ($arg_1, $arg_2, ..., $arg_n) { +<![CDATA[ +function foo ($arg_1, $arg_2, ..., $arg_n) +{ echo "颿°ã®ä¾\n"; return $retval; } +]]> </programlisting> </informalexample> </para> @@ -75,9 +79,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ function takes_array($input) { echo "$input[0] + $input[1] = ", $input[0]+$input[1]; } +]]> </programlisting> </informalexample> </para> @@ -97,12 +103,14 @@ <informalexample> <programlisting role="php"> -function add_some_extra(&$string) { +<![CDATA[ +function add_some_extra(&$string) { $string .= 'and something extra.'; } $str = 'This is a string, '; add_some_extra($str); echo $str; // 'This is a string, and something extra.' ãåºåãã¾ã +]]> </programlisting> </informalexample> </para> @@ -113,14 +121,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ function foo ($bar) { $bar .= ' and something extra.'; } $str = 'This is a string, '; foo ($str); echo $str; // 'This is a string, ' ãåºåãã¾ãã -foo (&$str); +foo (&$str); echo $str; // 'This is a string, and something extra.' ãåºåãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -136,11 +146,14 @@ <informalexample> <programlisting role="php"> -function makecoffee ($type = "cappucino") { +<![CDATA[ +function makecoffee ($type = "cappucino") +{ return "䏿¯ã® $type ãä½ãã¾ã\n"; } echo makecoffee (); echo makecoffee ("espresso"); +]]> </programlisting> </informalexample> </para> @@ -166,11 +179,14 @@ <informalexample> <programlisting role="php"> -function makeyogurt ($type = "acidophilus", $flavour) { +<![CDATA[ +function makeyogurt ($type = "acidophilus", $flavour) +{ return "Making a bowl of $type $flavour.\n"; } echo makeyogurt ("raspberry"); // æå¾ éãã«ã¯åä½ãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -190,11 +206,14 @@ <informalexample> <programlisting role="php"> -function makeyogurt ($flavour, $type = "acidophilus") { +<![CDATA[ +function makeyogurt ($flavour, $type = "acidophilus") +{ return "Making a bowl of $type $flavour.\n"; } echo makeyogurt ("raspberry"); // æå¾ éãã«åä½ãã¾ã +]]> </programlisting> </informalexample> </para> @@ -238,10 +257,13 @@ <informalexample> <programlisting role="php"> -function square ($num) { +<![CDATA[ +function square ($num) +{ return $num * $num; } echo square (4); // '16' ãåºåãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -251,10 +273,13 @@ <informalexample> <programlisting role="php"> -function small_numbers() { +<![CDATA[ +function small_numbers() +{ return array (0, 1, 2); } list ($zero, $one, $two) = small_numbers(); +]]> </programlisting> </informalexample> </para> @@ -263,11 +288,14 @@ è¨é¨ããã³å¤æ°ã¸ã®è¿ãå¤ãä»£å ¥ããéã®ä¸¡æ¹ã§ä½¿ç¨ããå¿ è¦ãããã¾ãã <informalexample> <programlisting role="php"> -function &returns_reference() { +<![CDATA[ +function &returns_reference() +{ return $someref; } -$newref =&returns_reference(); +$newref =& returns_reference(); +]]> </programlisting> </informalexample> </para> @@ -320,20 +348,23 @@ <example> <title>å¯å¤é¢æ°ã®ä¾</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { - echo "In foo()<br>\n"; + echo "In foo()<br>\n"; } -function bar( $arg = '' ) { - echo "In bar(); argument was '$arg'.<br>\n"; +function bar($arg = '') +{ + echo "In bar(); argument was '$arg'.<br>\n"; } $func = 'foo'; $func(); $func = 'bar'; -$func( 'test' ); +$func('test'); ?> +]]> </programlisting> </example> </para> Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.13 phpdoc/ja/language/oop.xml:1.14 --- phpdoc/ja/language/oop.xml:1.13 Wed Dec 12 15:54:01 2001 +++ phpdoc/ja/language/oop.xml Sun Dec 16 05:04:35 2001 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.14 $ --> <chapter id="language.oop"> <title>ã¯ã©ã¹ã¨ãªãã¸ã§ã¯ã</title> @@ -10,19 +11,23 @@ <informalexample> <programlisting role="php"> -<?php -class Cart { +<![CDATA[ +<?php +class Cart +{ var $items; // è²·ãç©ç¯ã®ä¸ã®ã¢ã¤ãã // $num åã® $artnr ãè²·ãç©ç¯ã«å ãã¾ã - function add_item ($artnr, $num) { + function add_item ($artnr, $num) + { $this->items[$artnr] += $num; } // $num åã® $artnr ãè²·ãç©ç± ããåºãã¾ã - function remove_item ($artnr, $num) { + function remove_item ($artnr, $num) + { if ($this->items[$artnr] > $num) { $this->items[$artnr] -= $num; return true; @@ -31,7 +36,8 @@ } } } -?> +?> +]]> </programlisting> </informalexample> </para> @@ -75,8 +81,10 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ /* 以ä¸ã®ã³ã¼ãã¯PHP 4ã§ã¯åä½ãã¾ããã */ -class Cart { +class Cart +{ var $todays_date = date("Y-m-d"); var $name = $firstname; var $owner = 'Fred ' . 'Jones'; @@ -84,18 +92,21 @@ } /* 以ä¸ã«æ£ããæ¹æ³ã示ãã¾ãã */ -class Cart { +class Cart +{ var $todays_date; var $name; var $owner; var $items; - function Cart() { + function Cart() + { $this->todays_date = date("Y-m-d"); $this->name = $GLOBALS['firstname']; /* çãªã©. . . */ } } +]]> </programlisting> </informalexample> </note> @@ -106,11 +117,15 @@ <informalexample> <programlisting role="php"> +<![CDATA[ +<?php $cart = new Cart; $cart->add_item("10", 1); $another_cart = new Cart; $another_cart->add_item("0815", 3); +?> +]]> </programlisting> </informalexample> @@ -139,6 +154,7 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // æ£ããã$ã¯ä¸ã¤ $cart->items = array("10" => 1); @@ -146,9 +162,10 @@ $cart->$items = array("10" => 1); // æ£ããããæå³ãã¦ãããã©ããã«ãããã -// $cart->$myvar ã¯ã $ncart->items ã¨ãªã +// $cart->$myvar ã¯ã $cart->items ã¨ãªã $myvar = 'items'; $cart->$myvar = array("10" => 1); +]]> </programlisting> </informalexample> @@ -160,7 +177,7 @@ ããªãã®ã§ãã代ããã«ãã¯ã©ã¹ã®ä¸ãããã®ã¯ã©ã¹å ã®é¢æ°ã夿°ã«ã¢ ã¯ã»ã¹ããããã«ãç似夿° $this ã使ç¨ãããã¨ãå¯è½ã§ãã$this ã¯ããèªåèªèº«ã®ãã¾ãã¯ãã«ã¬ã³ãã®ãªãã¸ã§ã¯ããã¨èªã¿å¤ããã㨠- ãã§ãã¾ããã¤ã¾ãã'$this->items[$artnr] += $num' ã¯ããåãã¯ã© + ãã§ãã¾ããã¤ã¾ãã'$this->items[$artnr] += $num' ã¯ããåãã¯ã© ã¹å ã®é å items ã® $artnr ã«ã¦ã³ã¿ã« $num ã追å ãããã¾ãã¯ãã« ã¬ã³ããªãã¸ã§ã¯ãå ã®é å items ã® $artnr ã«ã¦ã³ã¿ã« $num ã追å ãããã¨èªã¿å¤ãããã¨ãå¯è½ã§ãã @@ -186,13 +203,17 @@ <informalexample> <programlisting role="php"> -class Named_Cart extends Cart { +<![CDATA[ +class Named_Cart extends Cart +{ var $owner; - function set_owner ($name) { + function set_owner ($name) + { $this->owner = $name; } } +]]> </programlisting> </informalexample> @@ -206,10 +227,12 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $ncart = new Named_Cart; // ååä»ãã®ç± ã使 -$ncart->set_owner ("kris"); // ç± ã®ææè ã®ååãè¨å® +$ncart->set_owner("kris"); // ç± ã®ææè ã®ååãè¨å® print $ncart->owner; // ç± ã®ææè ãåºå -$ncart->add_item ("10", 1); // (ç± ããç¶æ¿ãããæ©è½) +$ncart->add_item("10", 1); // (ç± ããç¶æ¿ãããæ©è½) +]]> </programlisting> </informalexample> @@ -237,12 +260,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // PHP 3 ããã³ PHP 4ã§åä½ãã¾ã -class Auto_Cart extends Cart { - function Auto_Cart () { - $this->add_item ("10", 1); +class Auto_Cart extends Cart +{ + function Auto_Cart () + { + $this->add_item("10", 1); } } +]]> </programlisting> </informalexample> @@ -258,20 +285,24 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // PHP 3 㨠PHP 4ã®ä¸¡æ¹ã§åä½ -class Constructor_Cart extends Cart { - function Constructor_Cart ($item = "10", $num = 1) { - $this->add_item ($item, $num); +class Constructor_Cart extends Cart +{ + function Constructor_Cart ($item = "10", $num = 1) + { + $this->add_item($item, $num); } } // ãã¤ããããåã®ä¾ã¨åããã®ãè²·ã -$default_cart = new Constructor_Cart; +$default_cart = new Constructor_Cart; // å®éã«è²·ããã®ç¯ã«å ¥ãã... -$different_cart = new Constructor_Cart ("20", 17); +$different_cart = new Constructor_Cart("20", 17); +]]> </programlisting> </informalexample> @@ -284,20 +315,26 @@ <informalexample> <programlisting role="php"> -class A { - function A() { - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; - } +<![CDATA[ +class A +{ + function A() + { + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; + } } -class B extends A { - function C() { - "é常ã®é¢æ°<br>\n"; - } +class B extends A +{ + function C() + { + "é常ã®é¢æ°<br>\n"; + } } // PHP 3ã§ã¯ã³ã³ã¹ãã©ã¯ã¿ã¯ã³ã¼ã«ããã¾ãã $b = new B; +]]> </programlisting> </informalexample> @@ -317,25 +354,32 @@ <informalexample> <programlisting role="php"> -class A { - function A() { - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; - } - - function B() { - echo "ã¯ã©ã¹Aã®Bã¨ããååã®é常ã®é¢æ°<br>\n"; - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã¯ããã¾ãã<br>\n"; - } +<![CDATA[ +class A +{ + function A() + { + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; + } + + function B() + { + echo "ã¯ã©ã¹Aã®Bã¨ããååã®é常ã®é¢æ°<br>\n"; + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã¯ããã¾ãã<br>\n"; + } } -class B extends A { - function C() { - echo "é常ã®é¢æ°ã§ã<br>\n"; - } +class B extends A +{ + function C() + { + echo "é常ã®é¢æ°ã§ã<br>\n"; + } } // ããã«ãããB() ãã³ã³ã¹ãã©ã¯ã¿ã¨ãã¦ã³ã¼ã«ããã¾ãã $b = new B; +]]> </programlisting> </informalexample> @@ -371,8 +415,8 @@ </note> <para> - ãã¹ãã©ã¯ã¿ã¯ã<function>unset</function>ã¾ãã¯å¤æ°ã®ã¹ã³ã¼ããã - ã§ããã¨ã«ããã夿°ãç ´æ£ããã度ã«èªåçã«ã³ã¼ã«ããã颿°ã§ãã + ãã¹ãã©ã¯ã¿ã¯ã<function>unset</function>ã¾ãã¯ã¹ã³ã¼ããã + ã§ããã¨ã«ããããªãã¸ã§ã¯ããç ´æ£ããã度ã«èªåçã«ã³ã¼ã«ããã颿°ã§ãã PHPã«ã¯ãã¹ãã©ã¯ã¿ã¯ããã¾ããã </para> </sect1> @@ -394,21 +438,26 @@ <informalexample> <programlisting role="php"> -class A { - function example() { - echo "ãªãªã¸ãã«ã®é¢æ°A::example().<br>\n"; - } +<![CDATA[ +class A +{ + function example() + { + echo "ãªãªã¸ãã«ã®é¢æ°A::example().<br>\n"; + } } -class B extends A { - function example() { - echo "åå®ç¾©ããã颿°B::example().<br>\n"; - A::example(); - } +class B extends A +{ + function example() + { + echo "åå®ç¾©ããã颿°B::example().<br>\n"; + A::example(); + } } // ã¯ã©ã¹Aã®ãªãã¸ã§ã¯ãã¯ããã¾ãã -// ãã®ä¾ã¯ãããªãªã¸ãã«ã®é¢æ°A::example().<br>ããåºåãã¾ +// ãã®ä¾ã¯ãããªãªã¸ãã«ã®é¢æ°A::example().<br>ããåºåãã¾ // ã A::example(); @@ -416,9 +465,10 @@ $b = new B; // ãã®ä¾ã®åºåã¯æ¬¡ã®ããã«ãªãã¾ãã -// åå®ç¾©ããã颿°B::example().<br> -// ãªãªã¸ãã«ã®é¢æ°A::example().<br> +// åå®ç¾©ããã颿°B::example().<br> +// ãªãªã¸ãã«ã®é¢æ°A::example().<br> $b->example(); +]]> </programlisting> </informalexample> @@ -474,23 +524,29 @@ <informalexample> <programlisting role="php"> -class A { - function example() { - echo "A::example()ã§ããåºæ¬é¢æ°ãæä¾ãã¾ãã<br>\n"; - } +<![CDATA[ +class A +{ + function example() + { + echo "A::example()ã§ããåºæ¬é¢æ°ãæä¾ãã¾ãã<br>\n"; + } } -class B extends A { - function example() { - echo "B::example()ã§ããä»å çãªæ©è½ãæä¾ãã¾ãã<br>\n"; - parent::example(); - } +class B extends A +{ + function example() + { + echo "B::example()ã§ããä»å çãªæ©è½ãæä¾ãã¾ãã<br>\n"; + parent::example(); + } } $b = new B; // B::example()ãã³ã¼ã«ãããã®é¢æ°ã®ä¸ããA::example()ãã³ã¼ã«ããã¾ãã $b->example(); +]]> </programlisting> </informalexample> </sect1> @@ -536,13 +592,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ classa.inc: - class A { - var $one = 1; - - function show_one() { - echo $this->one; - } + class A + { + var $one = 1; + + function show_one() + { + echo $this->one; + } } page1.php: @@ -560,10 +619,11 @@ include("classa.inc"); $s = implode("", @file("store")); - unserialize($s); + $a = unserialize($s); - // ãªãã¸ã§ã¯ã$aã®é¢æ°show_oneã使ç¨ãã + // ãªãã¸ã§ã¯ã$aã®é¢æ°show_one()ã使ç¨ãã $a->show_one(); +]]> </programlisting> </informalexample> @@ -636,26 +696,31 @@ <informalexample> <programlisting role="php"> - -class foo { - function foo($name) { +<![CDATA[ +class foo +{ + function foo($name) + { // å é¨ã¸ã®åç §ã°ãã¼ãã«é å $globalref ã使 global $globalref; - $globalref[] = &$this; + $globalref[] = &$this; // name ãæå®ããå¤ã«è¨å® $this->setName($name); - // ãããåºå + // ãããåºå $this->echoName(); } - function echoName() { - echo "<br>",$this->Name; + function echoName() + { + echo "<br>",$this->Name; } - function setName($name) { - $this->Name = $name; + function setName($name) + { + $this->Name = $name; } } +]]> </programlisting> </informalexample> </para> @@ -668,25 +733,25 @@ <informalexample> <programlisting role="php"> - - $bar1 = new foo('set in constructor'); - $bar1->echoName(); - $globalref[0]->echoName(); - - /* åºå: - set in constructor - set in constructor - set in constructor */ - - $bar2 =& new foo('set in constructor'); - $bar2->echoName(); - $globalref[1]->echoName(); - - /* åºå: - set in constructor - set in constructor - set in constructor */ - +<![CDATA[ +$bar1 = new foo('set in constructor'); +$bar1->echoName(); +$globalref[0]->echoName(); + +/* åºå: +set in constructor +set in constructor +set in constructor */ + +$bar2 =& new foo('set in constructor'); +$bar2->echoName(); +$globalref[1]->echoName(); + +/* åºå: +set in constructor +set in constructor +set in constructor */ +]]> </programlisting> </informalexample> </para> @@ -709,8 +774,9 @@ </note> ä¸è¨ã®è¨è¿°ãæ£ãããã¨ã示ãããã«ä»¥ä¸ã®ã³ã¼ããè¦ã¦ã¿ã¾ãããã - <informalexample> + <informalexample> <programlisting role="php"> +<![CDATA[ // ããã§ãname ã夿´ãã¦ã¿ã¾ããã©ããªãã§ãããã? // $bar 㨠$globalref[0] ã®ä¸¡æ¹å ±ååãå¤ããã¨äºæ³ããããããã¾ãã... $bar1->setName('set from outside'); @@ -733,8 +799,8 @@ /* åºå: set from outside set from outside */ - - </programlisting> +]]> + </programlisting> </informalexample> </para> <para> @@ -742,39 +808,43 @@ <informalexample> <programlisting role="php"> - -class a { - function a($i) { - $this->value = $i; - // ããã§åç §ã使ãå¿ è¦ããªãçç±ãèãã¦ã¿ã¦ä¸ãã - $this->b = new b($this); +<![CDATA[ +class A +{ + function A($i) + { + $this->value = $i; + // ããã§åç §ã使ãå¿ è¦ããªãçç±ãèãã¦ã¿ã¦ä¸ãã + $this->b = new B($this); } - function createRef() { - $this->c = new b($this); + function createRef() + { + $this->c = new B($this); } - function echoValue() { - echo "<br>","class ",get_class($this),': ',$this->value; - } + function echoValue() + { + echo "<br>","class ",get_class($this),': ',$this->value; + } } - -class b { - - function b(&$a) { - $this->a = &$a; +class B +{ + function B(&$a) + { + $this->a = &$a; } - function echoValue() { - echo "<br>","class ",get_class($this),': ',$this->a->value; - } - + function echoValue() + { + echo "<br>","class ",get_class($this),': ',$this->a->value; + } } // 以ä¸ã®åç´ãªã³ãã¼ãã* å°ãä»ããè¡ã§æã¾ãããªãçµæãçãçç±ã // èãã¦ã¿ã¦ä¸ããã -$a =& new a(10); +$a =& new A(10); $a->createRef(); $a->echoValue(); @@ -789,13 +859,14 @@ /* åºå: -class a: 10 -class b: 10 -class b: 10 -class a: 11 -class b: 11 -class b: 11 +class A: 10 +class B: 10 +class B: 10 +class A: 11 +class B: 11 +class B: 11 */ +]]> </programlisting> </informalexample> </para>
Index: phpdoc/ja/language/functions.xml diff -u phpdoc/ja/language/functions.xml:1.8 phpdoc/ja/language/functions.xml:1.9 --- phpdoc/ja/language/functions.xml:1.8 Wed Dec 12 15:54:00 2001 +++ phpdoc/ja/language/functions.xml Sun Dec 16 05:04:35 2001 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.9 $ --> <chapter id="functions"> <title>颿°</title> @@ -10,10 +11,13 @@ <informalexample> <programlisting role="php"> -function foo ($arg_1, $arg_2, ..., $arg_n) { +<![CDATA[ +function foo ($arg_1, $arg_2, ..., $arg_n) +{ echo "颿°ã®ä¾\n"; return $retval; } +]]> </programlisting> </informalexample> </para> @@ -75,9 +79,11 @@ <informalexample> <programlisting role="php"> +<![CDATA[ function takes_array($input) { echo "$input[0] + $input[1] = ", $input[0]+$input[1]; } +]]> </programlisting> </informalexample> </para> @@ -97,12 +103,14 @@ <informalexample> <programlisting role="php"> -function add_some_extra(&$string) { +<![CDATA[ +function add_some_extra(&$string) { $string .= 'and something extra.'; } $str = 'This is a string, '; add_some_extra($str); echo $str; // 'This is a string, and something extra.' ãåºåãã¾ã +]]> </programlisting> </informalexample> </para> @@ -113,14 +121,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ function foo ($bar) { $bar .= ' and something extra.'; } $str = 'This is a string, '; foo ($str); echo $str; // 'This is a string, ' ãåºåãã¾ãã -foo (&$str); +foo (&$str); echo $str; // 'This is a string, and something extra.' ãåºåãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -136,11 +146,14 @@ <informalexample> <programlisting role="php"> -function makecoffee ($type = "cappucino") { +<![CDATA[ +function makecoffee ($type = "cappucino") +{ return "䏿¯ã® $type ãä½ãã¾ã\n"; } echo makecoffee (); echo makecoffee ("espresso"); +]]> </programlisting> </informalexample> </para> @@ -166,11 +179,14 @@ <informalexample> <programlisting role="php"> -function makeyogurt ($type = "acidophilus", $flavour) { +<![CDATA[ +function makeyogurt ($type = "acidophilus", $flavour) +{ return "Making a bowl of $type $flavour.\n"; } echo makeyogurt ("raspberry"); // æå¾ éãã«ã¯åä½ãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -190,11 +206,14 @@ <informalexample> <programlisting role="php"> -function makeyogurt ($flavour, $type = "acidophilus") { +<![CDATA[ +function makeyogurt ($flavour, $type = "acidophilus") +{ return "Making a bowl of $type $flavour.\n"; } echo makeyogurt ("raspberry"); // æå¾ éãã«åä½ãã¾ã +]]> </programlisting> </informalexample> </para> @@ -238,10 +257,13 @@ <informalexample> <programlisting role="php"> -function square ($num) { +<![CDATA[ +function square ($num) +{ return $num * $num; } echo square (4); // '16' ãåºåãã¾ãã +]]> </programlisting> </informalexample> </para> @@ -251,10 +273,13 @@ <informalexample> <programlisting role="php"> -function small_numbers() { +<![CDATA[ +function small_numbers() +{ return array (0, 1, 2); } list ($zero, $one, $two) = small_numbers(); +]]> </programlisting> </informalexample> </para> @@ -263,11 +288,14 @@ è¨é¨ããã³å¤æ°ã¸ã®è¿ãå¤ãä»£å ¥ããéã®ä¸¡æ¹ã§ä½¿ç¨ããå¿ è¦ãããã¾ãã <informalexample> <programlisting role="php"> -function &returns_reference() { +<![CDATA[ +function &returns_reference() +{ return $someref; } -$newref =&returns_reference(); +$newref =& returns_reference(); +]]> </programlisting> </informalexample> </para> @@ -320,20 +348,23 @@ <example> <title>å¯å¤é¢æ°ã®ä¾</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { - echo "In foo()<br>\n"; + echo "In foo()<br>\n"; } -function bar( $arg = '' ) { - echo "In bar(); argument was '$arg'.<br>\n"; +function bar($arg = '') +{ + echo "In bar(); argument was '$arg'.<br>\n"; } $func = 'foo'; $func(); $func = 'bar'; -$func( 'test' ); +$func('test'); ?> +]]> </programlisting> </example> </para> Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.13 phpdoc/ja/language/oop.xml:1.14 --- phpdoc/ja/language/oop.xml:1.13 Wed Dec 12 15:54:01 2001 +++ phpdoc/ja/language/oop.xml Sun Dec 16 05:04:35 2001 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.14 $ --> <chapter id="language.oop"> <title>ã¯ã©ã¹ã¨ãªãã¸ã§ã¯ã</title> @@ -10,19 +11,23 @@ <informalexample> <programlisting role="php"> -<?php -class Cart { +<![CDATA[ +<?php +class Cart +{ var $items; // è²·ãç©ç¯ã®ä¸ã®ã¢ã¤ãã // $num åã® $artnr ãè²·ãç©ç¯ã«å ãã¾ã - function add_item ($artnr, $num) { + function add_item ($artnr, $num) + { $this->items[$artnr] += $num; } // $num åã® $artnr ãè²·ãç©ç± ããåºãã¾ã - function remove_item ($artnr, $num) { + function remove_item ($artnr, $num) + { if ($this->items[$artnr] > $num) { $this->items[$artnr] -= $num; return true; @@ -31,7 +36,8 @@ } } } -?> +?> +]]> </programlisting> </informalexample> </para> @@ -75,8 +81,10 @@ </simpara> <informalexample> <programlisting role="php"> +<![CDATA[ /* 以ä¸ã®ã³ã¼ãã¯PHP 4ã§ã¯åä½ãã¾ããã */ -class Cart { +class Cart +{ var $todays_date = date("Y-m-d"); var $name = $firstname; var $owner = 'Fred ' . 'Jones'; @@ -84,18 +92,21 @@ } /* 以ä¸ã«æ£ããæ¹æ³ã示ãã¾ãã */ -class Cart { +class Cart +{ var $todays_date; var $name; var $owner; var $items; - function Cart() { + function Cart() + { $this->todays_date = date("Y-m-d"); $this->name = $GLOBALS['firstname']; /* çãªã©. . . */ } } +]]> </programlisting> </informalexample> </note> @@ -106,11 +117,15 @@ <informalexample> <programlisting role="php"> +<![CDATA[ +<?php $cart = new Cart; $cart->add_item("10", 1); $another_cart = new Cart; $another_cart->add_item("0815", 3); +?> +]]> </programlisting> </informalexample> @@ -139,6 +154,7 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // æ£ããã$ã¯ä¸ã¤ $cart->items = array("10" => 1); @@ -146,9 +162,10 @@ $cart->$items = array("10" => 1); // æ£ããããæå³ãã¦ãããã©ããã«ãããã -// $cart->$myvar ã¯ã $ncart->items ã¨ãªã +// $cart->$myvar ã¯ã $cart->items ã¨ãªã $myvar = 'items'; $cart->$myvar = array("10" => 1); +]]> </programlisting> </informalexample> @@ -160,7 +177,7 @@ ããªãã®ã§ãã代ããã«ãã¯ã©ã¹ã®ä¸ãããã®ã¯ã©ã¹å ã®é¢æ°ã夿°ã«ã¢ ã¯ã»ã¹ããããã«ãç似夿° $this ã使ç¨ãããã¨ãå¯è½ã§ãã$this ã¯ããèªåèªèº«ã®ãã¾ãã¯ãã«ã¬ã³ãã®ãªãã¸ã§ã¯ããã¨èªã¿å¤ããã㨠- ãã§ãã¾ããã¤ã¾ãã'$this->items[$artnr] += $num' ã¯ããåãã¯ã© + ãã§ãã¾ããã¤ã¾ãã'$this->items[$artnr] += $num' ã¯ããåãã¯ã© ã¹å ã®é å items ã® $artnr ã«ã¦ã³ã¿ã« $num ã追å ãããã¾ãã¯ãã« ã¬ã³ããªãã¸ã§ã¯ãå ã®é å items ã® $artnr ã«ã¦ã³ã¿ã« $num ã追å ãããã¨èªã¿å¤ãããã¨ãå¯è½ã§ãã @@ -186,13 +203,17 @@ <informalexample> <programlisting role="php"> -class Named_Cart extends Cart { +<![CDATA[ +class Named_Cart extends Cart +{ var $owner; - function set_owner ($name) { + function set_owner ($name) + { $this->owner = $name; } } +]]> </programlisting> </informalexample> @@ -206,10 +227,12 @@ <informalexample> <programlisting role="php"> +<![CDATA[ $ncart = new Named_Cart; // ååä»ãã®ç± ã使 -$ncart->set_owner ("kris"); // ç± ã®ææè ã®ååãè¨å® +$ncart->set_owner("kris"); // ç± ã®ææè ã®ååãè¨å® print $ncart->owner; // ç± ã®ææè ãåºå -$ncart->add_item ("10", 1); // (ç± ããç¶æ¿ãããæ©è½) +$ncart->add_item("10", 1); // (ç± ããç¶æ¿ãããæ©è½) +]]> </programlisting> </informalexample> @@ -237,12 +260,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // PHP 3 ããã³ PHP 4ã§åä½ãã¾ã -class Auto_Cart extends Cart { - function Auto_Cart () { - $this->add_item ("10", 1); +class Auto_Cart extends Cart +{ + function Auto_Cart () + { + $this->add_item("10", 1); } } +]]> </programlisting> </informalexample> @@ -258,20 +285,24 @@ <informalexample> <programlisting role="php"> +<![CDATA[ // PHP 3 㨠PHP 4ã®ä¸¡æ¹ã§åä½ -class Constructor_Cart extends Cart { - function Constructor_Cart ($item = "10", $num = 1) { - $this->add_item ($item, $num); +class Constructor_Cart extends Cart +{ + function Constructor_Cart ($item = "10", $num = 1) + { + $this->add_item($item, $num); } } // ãã¤ããããåã®ä¾ã¨åããã®ãè²·ã -$default_cart = new Constructor_Cart; +$default_cart = new Constructor_Cart; // å®éã«è²·ããã®ç¯ã«å ¥ãã... -$different_cart = new Constructor_Cart ("20", 17); +$different_cart = new Constructor_Cart("20", 17); +]]> </programlisting> </informalexample> @@ -284,20 +315,26 @@ <informalexample> <programlisting role="php"> -class A { - function A() { - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; - } +<![CDATA[ +class A +{ + function A() + { + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; + } } -class B extends A { - function C() { - "é常ã®é¢æ°<br>\n"; - } +class B extends A +{ + function C() + { + "é常ã®é¢æ°<br>\n"; + } } // PHP 3ã§ã¯ã³ã³ã¹ãã©ã¯ã¿ã¯ã³ã¼ã«ããã¾ãã $b = new B; +]]> </programlisting> </informalexample> @@ -317,25 +354,32 @@ <informalexample> <programlisting role="php"> -class A { - function A() { - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; - } - - function B() { - echo "ã¯ã©ã¹Aã®Bã¨ããååã®é常ã®é¢æ°<br>\n"; - echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã¯ããã¾ãã<br>\n"; - } +<![CDATA[ +class A +{ + function A() + { + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã<br>\n"; + } + + function B() + { + echo "ã¯ã©ã¹Aã®Bã¨ããååã®é常ã®é¢æ°<br>\n"; + echo "Aã®ã³ã³ã¹ãã©ã¯ã¿ã§ã¯ããã¾ãã<br>\n"; + } } -class B extends A { - function C() { - echo "é常ã®é¢æ°ã§ã<br>\n"; - } +class B extends A +{ + function C() + { + echo "é常ã®é¢æ°ã§ã<br>\n"; + } } // ããã«ãããB() ãã³ã³ã¹ãã©ã¯ã¿ã¨ãã¦ã³ã¼ã«ããã¾ãã $b = new B; +]]> </programlisting> </informalexample> @@ -371,8 +415,8 @@ </note> <para> - ãã¹ãã©ã¯ã¿ã¯ã<function>unset</function>ã¾ãã¯å¤æ°ã®ã¹ã³ã¼ããã - ã§ããã¨ã«ããã夿°ãç ´æ£ããã度ã«èªåçã«ã³ã¼ã«ããã颿°ã§ãã + ãã¹ãã©ã¯ã¿ã¯ã<function>unset</function>ã¾ãã¯ã¹ã³ã¼ããã + ã§ããã¨ã«ããããªãã¸ã§ã¯ããç ´æ£ããã度ã«èªåçã«ã³ã¼ã«ããã颿°ã§ãã PHPã«ã¯ãã¹ãã©ã¯ã¿ã¯ããã¾ããã </para> </sect1> @@ -394,21 +438,26 @@ <informalexample> <programlisting role="php"> -class A { - function example() { - echo "ãªãªã¸ãã«ã®é¢æ°A::example().<br>\n"; - } +<![CDATA[ +class A +{ + function example() + { + echo "ãªãªã¸ãã«ã®é¢æ°A::example().<br>\n"; + } } -class B extends A { - function example() { - echo "åå®ç¾©ããã颿°B::example().<br>\n"; - A::example(); - } +class B extends A +{ + function example() + { + echo "åå®ç¾©ããã颿°B::example().<br>\n"; + A::example(); + } } // ã¯ã©ã¹Aã®ãªãã¸ã§ã¯ãã¯ããã¾ãã -// ãã®ä¾ã¯ãããªãªã¸ãã«ã®é¢æ°A::example().<br>ããåºåãã¾ +// ãã®ä¾ã¯ãããªãªã¸ãã«ã®é¢æ°A::example().<br>ããåºåãã¾ // ã A::example(); @@ -416,9 +465,10 @@ $b = new B; // ãã®ä¾ã®åºåã¯æ¬¡ã®ããã«ãªãã¾ãã -// åå®ç¾©ããã颿°B::example().<br> -// ãªãªã¸ãã«ã®é¢æ°A::example().<br> +// åå®ç¾©ããã颿°B::example().<br> +// ãªãªã¸ãã«ã®é¢æ°A::example().<br> $b->example(); +]]> </programlisting> </informalexample> @@ -474,23 +524,29 @@ <informalexample> <programlisting role="php"> -class A { - function example() { - echo "A::example()ã§ããåºæ¬é¢æ°ãæä¾ãã¾ãã<br>\n"; - } +<![CDATA[ +class A +{ + function example() + { + echo "A::example()ã§ããåºæ¬é¢æ°ãæä¾ãã¾ãã<br>\n"; + } } -class B extends A { - function example() { - echo "B::example()ã§ããä»å çãªæ©è½ãæä¾ãã¾ãã<br>\n"; - parent::example(); - } +class B extends A +{ + function example() + { + echo "B::example()ã§ããä»å çãªæ©è½ãæä¾ãã¾ãã<br>\n"; + parent::example(); + } } $b = new B; // B::example()ãã³ã¼ã«ãããã®é¢æ°ã®ä¸ããA::example()ãã³ã¼ã«ããã¾ãã $b->example(); +]]> </programlisting> </informalexample> </sect1> @@ -536,13 +592,16 @@ <informalexample> <programlisting role="php"> +<![CDATA[ classa.inc: - class A { - var $one = 1; - - function show_one() { - echo $this->one; - } + class A + { + var $one = 1; + + function show_one() + { + echo $this->one; + } } page1.php: @@ -560,10 +619,11 @@ include("classa.inc"); $s = implode("", @file("store")); - unserialize($s); + $a = unserialize($s); - // ãªãã¸ã§ã¯ã$aã®é¢æ°show_oneã使ç¨ãã + // ãªãã¸ã§ã¯ã$aã®é¢æ°show_one()ã使ç¨ãã $a->show_one(); +]]> </programlisting> </informalexample> @@ -636,26 +696,31 @@ <informalexample> <programlisting role="php"> - -class foo { - function foo($name) { +<![CDATA[ +class foo +{ + function foo($name) + { // å é¨ã¸ã®åç §ã°ãã¼ãã«é å $globalref ã使 global $globalref; - $globalref[] = &$this; + $globalref[] = &$this; // name ãæå®ããå¤ã«è¨å® $this->setName($name); - // ãããåºå + // ãããåºå $this->echoName(); } - function echoName() { - echo "<br>",$this->Name; + function echoName() + { + echo "<br>",$this->Name; } - function setName($name) { - $this->Name = $name; + function setName($name) + { + $this->Name = $name; } } +]]> </programlisting> </informalexample> </para> @@ -668,25 +733,25 @@ <informalexample> <programlisting role="php"> - - $bar1 = new foo('set in constructor'); - $bar1->echoName(); - $globalref[0]->echoName(); - - /* åºå: - set in constructor - set in constructor - set in constructor */ - - $bar2 =& new foo('set in constructor'); - $bar2->echoName(); - $globalref[1]->echoName(); - - /* åºå: - set in constructor - set in constructor - set in constructor */ - +<![CDATA[ +$bar1 = new foo('set in constructor'); +$bar1->echoName(); +$globalref[0]->echoName(); + +/* åºå: +set in constructor +set in constructor +set in constructor */ + +$bar2 =& new foo('set in constructor'); +$bar2->echoName(); +$globalref[1]->echoName(); + +/* åºå: +set in constructor +set in constructor +set in constructor */ +]]> </programlisting> </informalexample> </para> @@ -709,8 +774,9 @@ </note> ä¸è¨ã®è¨è¿°ãæ£ãããã¨ã示ãããã«ä»¥ä¸ã®ã³ã¼ããè¦ã¦ã¿ã¾ãããã - <informalexample> + <informalexample> <programlisting role="php"> +<![CDATA[ // ããã§ãname ã夿´ãã¦ã¿ã¾ããã©ããªãã§ãããã? // $bar 㨠$globalref[0] ã®ä¸¡æ¹å ±ååãå¤ããã¨äºæ³ããããããã¾ãã... $bar1->setName('set from outside'); @@ -733,8 +799,8 @@ /* åºå: set from outside set from outside */ - - </programlisting> +]]> + </programlisting> </informalexample> </para> <para> @@ -742,39 +808,43 @@ <informalexample> <programlisting role="php"> - -class a { - function a($i) { - $this->value = $i; - // ããã§åç §ã使ãå¿ è¦ããªãçç±ãèãã¦ã¿ã¦ä¸ãã - $this->b = new b($this); +<![CDATA[ +class A +{ + function A($i) + { + $this->value = $i; + // ããã§åç §ã使ãå¿ è¦ããªãçç±ãèãã¦ã¿ã¦ä¸ãã + $this->b = new B($this); } - function createRef() { - $this->c = new b($this); + function createRef() + { + $this->c = new B($this); } - function echoValue() { - echo "<br>","class ",get_class($this),': ',$this->value; - } + function echoValue() + { + echo "<br>","class ",get_class($this),': ',$this->value; + } } - -class b { - - function b(&$a) { - $this->a = &$a; +class B +{ + function B(&$a) + { + $this->a = &$a; } - function echoValue() { - echo "<br>","class ",get_class($this),': ',$this->a->value; - } - + function echoValue() + { + echo "<br>","class ",get_class($this),': ',$this->a->value; + } } // 以ä¸ã®åç´ãªã³ãã¼ãã* å°ãä»ããè¡ã§æã¾ãããªãçµæãçãçç±ã // èãã¦ã¿ã¦ä¸ããã -$a =& new a(10); +$a =& new A(10); $a->createRef(); $a->echoValue(); @@ -789,13 +859,14 @@ /* åºå: -class a: 10 -class b: 10 -class b: 10 -class a: 11 -class b: 11 -class b: 11 +class A: 10 +class B: 10 +class B: 10 +class A: 11 +class B: 11 +class B: 11 */ +]]> </programlisting> </informalexample> </para>