svn: /phpdoc/kr/trunk/language/oop5/ references.xml

From: Date: Tue, 07 Oct 2014 14:57:59 +0000
Subject: svn: /phpdoc/kr/trunk/language/oop5/ references.xml
Groups: php.doc.kr 
Request: Send a blank email to doc-kr+get-1928@lists.php.net to get a copy of this message
acidd15 Tue, 07 Oct 2014 14:57:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=335025 Log: initial translate Changed paths: A phpdoc/kr/trunk/language/oop5/references.xml Added: phpdoc/kr/trunk/language/oop5/references.xml =================================================================== --- phpdoc/kr/trunk/language/oop5/references.xml (rev 0) +++ phpdoc/kr/trunk/language/oop5/references.xml 2014-10-07 14:57:59 UTC (rev 335025) @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision$ --> +<!-- EN-Revision: 315146 Maintainer: acidd15 Status: ready --> +<!-- Reviewed: no --> + + <sect1 xml:id="language.oop5.references" xmlns="http://docbook.org/ns/docbook"> + <title>객체와 참조</title> + <para> + PHP 5 OOP에서 자주 언급되는 키포인트중에 하나가 바로 "객체는 기본적으로 passed by reference 이다" 입니다. + 이것은 옳은 말은 아닙니다. 이 섹션에서는 몇가지 예제를 통해 그것을 바로잡을 것입니다. + </para> + + <para> + PHP의 참조는 별칭입니다. 이는 서로 다른 변수가 같은 값을 사용할 수 있게 합니다. + PHP 5 이후에는 객체자체를 변수에 지니지 않습니다. 변수는 그저 객체 식별자를 가지게 되어, 식별자는 진짜 객체를 찾기 위한 용도로 사용됩니다. + 객체가 인자로 넘어갈때, 다른변수에 반환 또는 할당될때, 이 변수들은 별칭이 아닙니다.: 식별자의 복사하여 가지게 되며, 이 식별자들은 같은 객체를 가리킵니다. + </para> + + <example> + <title>References and Objects</title> + <programlisting role="php"> +<![CDATA[ +<?php +class A { + public $foo = 1; +} + +$a = new A; +$b = $a; // $a 와 $b 는 같은 식별자를 가집니다. + // ($a) = ($b) = <id> +$b->foo = 2; +echo $a->foo."\n"; + + +$c = new A; +$d = &$c; // $c 와 $d 는 참조이다 + // ($c,$d) = <id> + +$d->foo = 2; +echo $c->foo."\n"; + + +$e = new A; + +function foo($obj) { + // ($obj) = ($e) = <id> + $obj->foo = 2; +} + +foo($e); +echo $e->foo."\n"; + +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +2 +2 +2 +]]> + </screen> + </example> + </sect1> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"~/.phpdoc/manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> Property changes on: phpdoc/kr/trunk/language/oop5/references.xml ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL Added: svn:eol-style + native

« previous php.doc.kr (#1928) next »