[PHP]Cloning

개발관련/PHP 2012. 4. 20. 15:17 |
";
  }
  function __clone() {
    echo "Existing beverage was cloned.
"; } } $a = new Beverage(); $a->name = "coffee"; $b = $a; // always a reference with objects $b->name = "tea"; echo $a->name; echo "
"; $c = clone $a; $c->name = "orange juice"; echo $a->name; echo "
"; echo $c->name; ?>

New beverage was created.
tea
Existing beverage was cloned.
tea
orange juice

'개발관련 > PHP' 카테고리의 다른 글

[PHP]Constructors  (0) 2012.04.20
[PHP]Comparison  (0) 2012.04.20
[PHP]Class Example 5  (0) 2012.04.20
[PHP]Class Example 4  (0) 2012.04.20
[PHP]Class Example 3  (0) 2012.04.20
Posted by 파노카페
: