$ This-> $ function () in PHP what does it mean?

Source: Internet
Author: User
$ This-& gt; $ function () in PHP? Dear friends, recently, my younger brother is reading the code of group buying every day. The result shows this code in/modules/index. mod. php:
function ModuleObject( $config ){$this->MasterObject($config);$runCode = Load::moduleCode($this);$this->$runCode();}

In the fifth line of code, $ this-> $ runCode (); does this sentence have any special meaning in PHP? I am not trained in PHP, so I don't understand some basic rules that are not commonly used. I hope you will be grateful for your guidance.


Reply to discussion (solution)

This is a class, and the code is more than that.

Class ModuleObject extends MasterObject {function ModuleObject ($ config) {$ this-> MasterObject ($ config); $ runCode = Load: moduleCode ($ this ); $ this-> $ runCode ();} function Main () {$ clientUser = get ('u', 'int'); if ($ clientUser! = '') {Handler ('cookier')-> setVar ('finderid', $ clientUser); handler ('cookier')-> setVar ('findtime ', time () ;}$ data = logic ('product')-> display (); $ data | header ('Location :'. rewrite ('? Mod = subscribe & code = mail '); $ product = $ data ['product']; $ this-> Title = $ data ['mutidview']? '': $ Product ['name']; include handler ('Template')-> file ($ data ['file']);} function ExpressConfirm () {$ oid = $ this-> Get ['id']; $ result = $ this-> OrderLogic-> orderExpressConfirm ($ oid); if ($ result) {$ this-> Messager (_ ('receipt confirmed. this transaction is complete! '),'? Mod = me & code = order');} else {$ this-> Messager (_ ('invalid order number! '),'? Mod = me & code = order ');}}}

This is the code of the class. I have checked the parent class and this class, and there are no related functions.

Manual cloud:

Variable functions
PHP supports the concept of variable functions. This means that if a variable name has parentheses, PHP will look for a function with the same name as the value of the variable and will try to execute it.

Manual cloud:

Variable functions
PHP supports the concept of variable functions. This means that if a variable name has parentheses, PHP will look for a function with the same name as the value of the variable and will try to execute it.
Are there any restrictions on the domain searched by the predecessors? For example: all non-class functions in the currently referenced file/all non-class and class member functions in the currently referenced file/all class static functions in the currently referenced file/

$ This-> $ runCode ();
This must be in your class.

Class ModuleObject extends MasterObject
Go to his parent class and public class to search
Go to the configuration file config. php (usually called this) and check the introduced class file.

$ RunCode = Load: moduleCode ($ this );
$ This-> $ runCode ();
Does the $ runCode in the second line have a relationship with the $ runCode in the first line?

$ RunCode = Load: moduleCode ($ this );
$ This-> $ runCode ();
Does the $ runCode in the second line have a relationship with the $ runCode in the first line?
This has been found, as said on the third floor, the variable function, the string returned by $ runCode in the first line represents the function name. Example:

    $func = 'Main';    $func();    function Main(){        echo "This is a variable function";    }

The Main function is run, and the searched domain is a non-member function within the scope of the variable.

Is in the execution class
$ RunCode
This function.


See echo $ runCode.

I want to ask extends MasterObject

Where is the inherited parent class?

Is it a basic php class?

Cannot find MasterObject

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.