Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class A {
- public static $object;
- public function createb()
- { return new B(self::$object); }
- }
- class B {
- public $object;
- public function __construct($object)
- { $this->object = $object; }
- }
- $a = new A;
- $a::$object = (object) ['val' => 1];
- $b1 = $a->createb();
- $a::$object = (object) ['val' => 2];
- $b2 = $a->createb();
- print_r($b1);
- print_r($b2);
- /* Output:
- B Object
- (
- [object] => stdClass Object
- (
- [val] => 1
- )
- )
- B Object
- (
- [object] => stdClass Object
- (
- [val] => 2
- )
- )
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement