Home  >  Article  >  Backend Development  >  【php】验证CI框架controller是不是单例

【php】验证CI框架controller是不是单例

WBOY
WBOYOriginal
2016-06-13 11:42:361069browse

【php】验证CI框架controller是否单例

通过不同浏览器、相同浏览器进行set/get操作,确认contoller是多例的,每次请求均会实例化一次,类似struts2的action。?

?

可以直接定义类变量,不会受多线程的影响。

?

<?phpclass Info extends CI_Controller {	private $userId="0";	public function __construct() {		parent::__construct();	}		function set(){		$this ->userId = "234";		var_dump($this ->userId) ;	}		function get(){		var_dump($this ->userId) ;	}}

?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn