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

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

WBOY
Release: 2016-06-13 11:42:36
Original
1096 people have browsed it

【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) ;	}}
Copy after login

?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template