Zend framework Zend会话问题(初学者)
我在自学Zend am,但在使用会话调用视图助手操作时遇到了问题 我的控制器:Zend framework Zend会话问题(初学者),zend-framework,session,zend-view,zend-session,Zend Framework,Session,Zend View,Zend Session,我在自学Zend am,但在使用会话调用视图助手操作时遇到了问题 我的控制器: <?php class SessionController extends Zend_Controller_Action { protected $session; public function init() //Like a constructor { $this->_helper->viewRenderer->setNoRender(); // W
<?php
class SessionController extends Zend_Controller_Action
{
protected $session;
public function init() //Like a constructor
{
$this->_helper->viewRenderer->setNoRender(); // Will not automatically go to views/Session
$this->_helper->getHelper('layout')->disableLayout(); // Will not load the layout
}
public function preDispatch() //Invokes code before rendering. Good for sessions/cookies etc.
{
$this->session = new Zend_Session_Namespace(); //Create session
if(!$this->session->__isset('view'))
{
$this->session->view = $this->view; //if the session doesn't exist, make it's view default
}
}
public function printthingAction()
{
echo $this->session->view->tabbedbox($this->getRequest()->getParam('textme'));
}
}
?>
我的视图助手
<?php
class App_View_Helper_Tabbedbox extends Zend_View_Helper_Abstract
{
public $wordsauce = "";
public function tabbedbox($message = "")
{
$this->wordsauce .= $message;
return '<p>' . $this->wordsauce . "</p>";
}
}
?>
我的看法是:
<p>I GOT TO THE INDEX VIEW</p>
<input id='textme' type='input'/>
<input id='theButton' type='submit'/>
<div id="putstuffin"></div>
<script type="text/javascript">
$(function()
{
$("#theButton").click(function()
{
$.post(
"session/printthing",
{'textme' : $("#textme").val()},
function(response)
{
$("#putstuffin").append(response);
});
});
});
</script>
我进入了索引视图
$(函数()
{
$(“#按钮”)。单击(函数()
{
美元邮政(
“会话/打印内容”,
{'textme':$(“#textme”).val(),
功能(响应)
{
$(“#puttuffin”)。追加(回复);
});
});
});
当我第一次点击按钮时,它就工作了,并像预期的那样附加我的单词。但是,每次之后,它都会给我以下错误消息:
警告:call_user_func_array()[function.call user func array]:第一个参数应该是有效回调,“\uu PHP_complete_Class::tabbedbox”在第341行的C:\xampp\htdocs\BC\library\Zend\View\Abstract.PHP中给出
我几乎一行一行地复制了Zendcasts.com视频,但它仍然不起作用。好像我的会话被破坏了或者什么的。我将永远感谢任何能告诉我发生了什么的人。当您在会话中存储对象时,实际上是在存储它的序列化表示。之所以出现_PHP_complete_Class::tabbedbox,是因为在后续请求中,PHP忘记了App_View_Helper_tabbedbox是什么 解决方案:确保在调用Zend_Session::start()之前包含App_View_Helper_选项卡框类文件 最好的方法是将其放在应用程序的开头:
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();