[ create a new paste ] login | about

Link: http://codepad.org/ZkrhRIev    [ raw code | output | fork ]

PHP, pasted on Oct 18:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
class test
{
function setSomeProp($s) { $this->prop = $s;}
function getSomeProp() { return $this->prop;}
}

$a = new test();
//$b = &$a;
//$b = unserialize(serialize($a)); 
$b = clone $a;
$b->setSomeProp('test');
$a->setSomeProp('failed');

echo $b->getSomeProp(); //returns 'test'
echo "\n";
echo $a->getSomeProp(); //returns 'test'


Output:
1
2
test
failed


Create a new paste based on this one


Comments: