「 "Questions about PHP callback functions

Source: Internet
Author: User
「 Help 」 questions about PHP callback function this post was last edited by kericw from 2013-11-0115:37:40. could you please tell me, in PHP, how does one implement the EventStack yywatcher method to return the obtained data to welcome. the callback function specified by php. I am asking for help about the PHP callback function.
At the end of this post, kericw edited his preferred dish at 15:37:40 on November 11,. could you tell me how to use the NotifyWatcher method of EventStack in PHP to return the obtained data to welcome. where did I write the callback function specified by php ???

Error: 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;

// Closure function (callback)
$ FGetSettings = function ($ oSettingDaemon ){
// Set the data model for the system returned by processing the callback
Echo $ oSettingDaemon;
};

// Request data prototype
$ 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 (){
// Store key information to the Log table of the data source
// Determine whether to output the debugging information to the page based on the debugging switch.
}
Function _ toString (){
}
# ##
Public function addEvent ($ sStamp = "ISSUE_TRACK", $ sValue, $ fHandler = null, $ msler = null ){
/* SStamp: the message stamp.
* SValue: serialized array
* FHandler (function): Anonymous callback function
* MScope (mixed type): context of the callback function,
* Null indicates that the passed handler function is a global function,
* The String type indicates that the input handler function is a static function of the scope class,
* The object type indicates that the passed 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-> policywatcher ($ iKey );
Return $ iKey;
}
Public function addWatcher ($ oWatcher, $ sWatchStamp ){
}
# C ##
Public function clearEventStack (){
// Clear the event stack
}
# E ##
Public function exportEventStack (){
// Output debugging information
}
# G ##
Public function getStack ($ iStackId ){
// Return the stack list or specified stack content based on whether the stack sequence number is provided
}
# N ##
Private function notifyWatcher ($ iKey ){
// Push the event to the corresponding 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, perform specific operations based on 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 ){
// Remove the specified Observer
}
}


?>
PHP? Callback callback PHP shared:
------ Solution --------------------
Only one view of $ 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.