工具描述:
可以设置Session,销毁Session。属于InitPHP框架工具类,需要通过$this->getUtil()方法获取
使用方法:
$session = $this->getUtil('session');
接口描述:
接口:$session->set($key, $value='') 设置session
| 参数 |
类型 |
是否必须 |
描述 |
| $key |
String |
是 |
key值,可以为单个key值,也可以为数组 |
| $value |
String |
是 |
value值 |
接口:$session->get($key) 获取session
| 参数 |
类型 |
是否必须 |
描述 |
| $key |
String |
是 |
key值,可以为单个key值,也可以为数组 |
接口:$session->del($key) 删除session
| 参数 |
类型 |
是否必须 |
描述 |
| $key |
String |
是 |
session名称 |
接口:$session->clear() 清除session
实例:
class indexController extends Controller {
public $initphp_list = array('test');
public function run() {
$queue = $this->getUtil('queue');
$queue->set('v1');
$queue->set('v2');
$queue->set('v3');
$queue->set('v4');
echo $queue->get();
$this->view->display(); //模板显示
}
public function test() {
echo 'Hello World';
}
/**
* @return testService
*/
private function getTestService() {
return InitPHP::getService('test','test');
}
}