相關PHP回呼函數的烏雲

來源:互聯網
上載者:User
有關PHP回呼函數的烏雲。
本人較菜,請問各位俠士,如何在PHP中達到EventStack的NotifyWatcher方法可以將取得的資料返還給welcome.php指定的回呼函數,我哪裡寫的不對啊 ???

出現的錯誤為:Fatal error: Function name must be a string in /home/latel/Workspace/new_zhebo/module/EventStack.php on line ××

/app/welcome.php

 
if (!defined("__IS_ROOT")) die("Access Denied");

global $EventStack;

//閉包函數(回調)
$fGetSettings = function($oSettingDaemon) {
//處理回調返回的系統設定資料模型
echo $oSettingDaemon;
};

//請求資料原型
$EventStack->addEvent(
"DATA_REQUEST",
serialize(array(
array(
"request" => "settingDaemon"
)
)),
$fGetSettings,
null
);
?>




/EventStack.php
//事件堆棧處理組件
/*數
*/
//已知的事件戳記
/*
*/

if (!defined("__IS_ROOT")) die("Access Denied");

class EventStack extends Init{
private $_aWatcherRegistry = array();//登入的觀察者列表
private $_aEventStack = array();//事件堆棧
private $_aCallbackRegistry = array();//登入的回呼函數

function __construct() {
}
function __destruct() {
//將關鍵資訊儲存至資料來源的Log表
//根據調試開關,決定是否輸出調試資訊至頁面
}
function __toString() {
}
##A##
public function addEvent($sStamp = "ISSUE_TRACK", $sValue, $fHandler = null, $mScope = null) {
/*sStamp: 此條訊息的戳記
*sValue: 序列化的數組
* fHandler(function): 匿名回呼函數
* mScope(mixed type): 回呼函數的上下文環境,
* null表示傳入的handler函數是一個全域函數,
* 字串類型表示傳入的handler函數是scope類的靜態函數,
* 物件類型表示傳入的scope是一個對象,handler函數是對象的一個方法
*/
$this->_aEventStack[] = array(
"stamp" => $sStamp,
"value" => $sValue,
"handler" => $fHandler,
"scope" => $mScope,
"timestamp" => time()
);
$iKey = sizeof($this->_aEventStack) - 1;
$this->notifyWatcher($iKey);
return $iKey;
}
public function addWatcher($oWatcher, $sWatchStamp) {
}
##C##
public function clearEventStack() {
//清空事件堆棧
}
##E##
public function exportEventStack() {
//輸出調試資訊
}
##G##
public function getStack($iStackId) {
//根據是否提供堆棧序號,返回堆棧列表或指定堆棧的內容
}
##N##
private function notifyWatcher($iKey) {
//推送事件至相應的觀察者
if (array_key_exists($this->_aEventStack[$iKey]["stamp"], $this->_aWatcherRegistry)) {
$mCallback = $this->_aWatcherRegistry[$this->_aEventStack[$iKey]["stamp"]](
$this->_aEventStack[$iKey]["stamp"],
$this->_aEventStack[$iKey]["value"],
$this->_aEventStack[$iKey]["handler"],
$this->_aEventStack[$iKey]["scope"]
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.