<?php
class A {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function copyName(A $from) {
$this->name = $from->name;
}
public function __toString()
{
return $this->name;
}
}
$a1 = new A('test1');
$a2 = new A('test2');
echo $a1.PHP_EOL;
$a1->copyName($a2);
echo $a1.PHP_EOL;
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme