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

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

Jun 13, 2016 pm 12:31 PM
controller function this

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

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

?

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

?

<?php class Info extends CI_Controller {

	private $userId="0";

	public function __construct() {
		parent::__construct();
	}

	
	function set(){
		$this ->userId = "234";
		var_dump($this -&gt;userId) ;
	}
	
	function get(){
		var_dump($this -&gt;userId) ;
	}

}

Copy after login

?

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that SpringBoot cannot scan the Controller How to solve the problem that SpringBoot cannot scan the Controller May 14, 2023 am 08:10 AM

How to solve the problem that SpringBoot cannot scan the Controller

What does function mean? What does function mean? Aug 04, 2023 am 10:33 AM

What does function mean?

How to add URL prefix to SpringBoot multiple controllers How to add URL prefix to SpringBoot multiple controllers May 12, 2023 pm 06:37 PM

How to add URL prefix to SpringBoot multiple controllers

What is the purpose of the 'enumerate()' function in Python? What is the purpose of the 'enumerate()' function in Python? Sep 01, 2023 am 11:29 AM

What is the purpose of the 'enumerate()' function in Python?

Detailed explanation of the role and function of the MySQL.proc table Detailed explanation of the role and function of the MySQL.proc table Mar 16, 2024 am 09:03 AM

Detailed explanation of the role and function of the MySQL.proc table

The usage and function of Vue.use function The usage and function of Vue.use function Jul 24, 2023 pm 06:09 PM

The usage and function of Vue.use function

What is the usage of js function What is the usage of js function Oct 07, 2023 am 11:25 AM

What is the usage of js function

file_exists() function in PHP file_exists() function in PHP Sep 14, 2023 am 08:29 AM

file_exists() function in PHP

See all articles