"Questions about the PHP callback function

Source: Internet
Author: User
"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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.