Zend framework 有什么不同吗';默认值';和';默认值';在zend默认会话名称空间中?
我正在zend框架中使用会话 问题是我需要知道两者之间有区别吗Zend framework 有什么不同吗';默认值';和';默认值';在zend默认会话名称空间中?,zend-framework,Zend Framework,我正在zend框架中使用会话 问题是我需要知道两者之间有区别吗 new Zend_Session_Namespace("default"); 及 在我的应用程序中,我使用了这两种方法,似乎代码工作不正常, 如果有差异,正确的使用方法是什么 这是我的密码 <?php class Admin_DashboardController extends Zend_Controller_Action { function init() { // }
new Zend_Session_Namespace("default");
及
在我的应用程序中,我使用了这两种方法,似乎代码工作不正常,
如果有差异,正确的使用方法是什么
这是我的密码
<?php
class Admin_DashboardController extends Zend_Controller_Action
{
function init()
{
//
}
/**
* Add hotelId to default session
* redirect to admin/hotels if hotelId is not avialble
*/
public function indexAction()
{
$params = $this->getRequest()->getParams();
$hotelid = NULL;
$config_session = new Zend_Session_Namespace("default");
$config_session->hotelid = $params['id'];
if(isset($params['id']) && !empty($params['id'])){
}else{
//redirect user to select hotels page
$redirector = new Zend_Controller_Action_Helper_Redirector();
$url = array(
'action' => 'admin/hotels/index'
);
$redirector->gotoRouteAndExit($url);
}
}
}
Zend\u Session\u名称空间
在内部所做的全部工作是在$\u Session
超全局内创建一个命名数组。由于PHP中的数组键区分大小写,“Default”和“Default”将被视为单独的名称空间
您可以使用任意一个,如果希望使用相同的数据,请保持一致
<?php
class Admin_DashboardController extends Zend_Controller_Action
{
function init()
{
//
}
/**
* Add hotelId to default session
* redirect to admin/hotels if hotelId is not avialble
*/
public function indexAction()
{
$params = $this->getRequest()->getParams();
$hotelid = NULL;
$config_session = new Zend_Session_Namespace("default");
$config_session->hotelid = $params['id'];
if(isset($params['id']) && !empty($params['id'])){
}else{
//redirect user to select hotels page
$redirector = new Zend_Controller_Action_Helper_Redirector();
$url = array(
'action' => 'admin/hotels/index'
);
$redirector->gotoRouteAndExit($url);
}
}
}