"Help" questions about PHP callback function
This post was last edited by KERICW on 2013-11-01 15:37:40
I more vegetables, I ask you chevalier, how to achieve Eventstack in PHP Notifywatcher method can be obtained data back to the welcome.php specified callback function, where I write the wrong ah???
The error that appears is: Fatal error:function name must be a string in/home/latel/workspace/new_zhebo/module/eventstack.php on Linexx
/app/welcome.php
if (!defined ("__is_root")) Die ("Access Denied");
Global $EventStack;
Closure function (callback)
$fGetSettings = function ($oSettingDaemon) {
Processing the system Settings data model returned by the callback
Echo $oSettingDaemon;
};
Request Data prototypes
$EventStack->addevent (
"Data_request",
Serialize (Array (
Array
"Request" = "Settingdaemon"
)
)),
$fGetSettings,
Null
);
?>
/eventstack.php
Event Stack Processing component
/* Number
*/
Known event stamps
/*
*/
if (!defined ("__is_root")) Die ("Access Denied");
Class Eventstack extends init{
Private $_awatcherregistry = Array ();//List of registered observers
Private $_aeventstack = Array ();//Event stack
Private $_acallbackregistry = Array ();//Registered callback function
function __construct () {
}
function __destruct () {
Storing key information in the log table of the data source
Depending on the debug switch, decide whether to output debugging information to the page
}
function __tostring () {
}
# #A # #
Public Function addevent ($sStamp = "Issue_track", $sValue, $fHandler = null, $mScope = null) {
/*sstamp: The stamp of this message
*svalue: Serialized Array
* Fhandler (function): Anonymous callback function
* MScope (mixed type): The context of the callback function,
* NULL indicates that the incoming handler function is a global function,
* The string type indicates that the passed-in handler function is a static function of the scope class.
* The object type indicates that the passed-in scope is an object, and the handler function is a method of the object
*/
$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 () {
Emptying the event stack
}
# #E # #
Public Function Exporteventstack () {
Output Debugging information
}
# #G # #
Public Function Getstack ($iStackId) {
Returns the Stack list or the contents of the specified stack, depending on whether the stack ordinal is supplied
}
# #N # #
Private Function Notifywatcher ($iKey) {
Push events to the appropriate observer
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"]
);
If a callback function is specified, the specific action is taken according to the data returned by the Observer
if (Isset ($this->_aeventstack[$iKey ["Fhandler"]) &&! $mCallback) {
$func = $this->_aeventstack[$iKey] ["Fhandler"];
$func ($mCallback);
} else {
$func (NULL);
}
}
}
# #R # #
Public Function Removewatcher ($sWatchStamp) {
Removes the specified observer
}
}
?>
PHP? Callback Callback PHP
Share to:
------Solution--------------------
See only once $fGetSettings