我在教自己Zend,並在使用我的會話調用View Helper操作時遇到問題。Zend Sessions問題(初學者)
我的控制器:
<?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>
我第一次點擊theButton,它的工作原理,並追加像我的話它應該。但是,對於每一次後,它給了我這個錯誤信息:
警告:call_user_func_array()[function.call-user-func-array]:第一個參數預計是一個有效的回調'__PHP_Incomplete_Class :: tabbedbox'是在C:\ xampp \ htdocs \ BC \ library \ Zend \ View \ Abstract.php上線341
我複製Zendcasts.com視頻幾乎行爲線,它仍然無法正常工作。好像我的會話正在被破壞或者什麼東西。我會永遠感謝任何能告訴我發生了什麼的人。
這就是它!謝謝。 – Ethan 2009-06-17 18:59:10