「 Help 」 questions about PHP callback functions

Source: Internet
Author: User
"Help": Questions about PHP callback functions. This post was last edited by kericw at 15:37:40, January 1 ,.

PHP callback

I am a good expert. could you tell me how to use the EventStack yywatcher method 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

 AddEvent ("DATA_REQUEST", serialize (array ("request" => "settingDaemon"), $ fGetSettings, null);?>



/EventStack. php

 _ 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 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 Specify the callback function and perform the specific operation if (isset ($ this-> _ aEventStack [$ iKey] ["fHandler"]) based on the data returned by the Observer. &! $ MCallback) {$ func = $ this-> _ aEventStack [$ iKey] ["fHandler"]; $ func ($ mCallback );} else {$ func (null) ;}}## R ## public function removeWatcher ($ sWatchStamp) {// remove the specified observer}?>


Reply to discussion (solution)

Only one view of $ fGetSettings

Only one view of $ fGetSettings

Moderator, can you tell me more? I have read your answer but I don't understand it very well.

I want,

The welcome. php page registers the callback function to EventStack using the EventStack-> addEvent method. when EventStack obtains the corresponding data, it brings the data to the registered callback function for execution.

I have poor language skills.

Do you mean global $ fGetSettings?

Function name must be a string
The function name must be a string.
You did not give an error location, and I cannot guess it!

Since $ fGetSettings is a closure, where do you need to use it?
But the code snippet you provided does not contain

Function name must be a string
The function name must be a string.
You did not give an error location, and I cannot guess it!

Since $ fGetSettings is a closure, where do you need to use it?
But the code snippet you provided does not contain


The error row is in the 72nd row of EventStack. php.
The closure function is passed to the 37 rows of EventStack. php.

The closure is used as a parameter and saved to the private array attribute $ _ aEventStack of this object ($ EventStack ).
$ After EventStack obtains the data, it will re-fetch the function from the array in 72 rows and pass the obtained data as a parameter to the function.

Well, it seems that I lack the art of asking questions ..

Please help, or the project will be placed here ......

You can only rely on yourself.

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.