<?php namespace app\common\model; use SplObserver; use SplSubject; use SplObjectStorage; class User implements SplSubject{ private $email; private $username; private $mobile; private $password; /** * @var SplObjectStorage */ private $observers = NULL; public function __construct($email, $username, $mobile, $password) { $this->email = $email; $this->username = $username; $this->mobile = $mobile; $this->password = $password; $this->observers = new SplObjectStorage(); } public function attach(SplObserver $observer) { $this->observers->attach($observer); } public function detach(SplObserver $observer) { $this->observers->detach($observer); } public function notify() { $userInfo = array( 'username' => $this->username, 'password' => $this->password, 'email' => $this->email, 'mobile' &
SplSubject 内容陈述
最新推荐文章于 2024-05-06 11:05:52 发布