In phpmysqli-> and: What is the difference?

Source: Internet
Author: User
I see two different ways of writing. I don't know what the difference between them is? {Code...} I see two different ways of writing. I don't know what the difference is between them?

mysqli->commitmysqli::commit

Reply content:

I see two different ways of writing. I don't know what the difference between them is?

mysqli->commitmysqli::commit

->Used to accessInstanceGenerally, the left side is a class instance (or$this), The right side is a function or attribute. arrows can also access static functions through class instances.

::Used to accessStaticA Member or constant that accesses a member of the parent class. Generally, the left side is a class name, orself,parent,staticKeyword. The right side is a static function, static attribute, and constant.

 Property; // The function print $ xxoo-> func () to access the instance; // You can also use the instance to access static members. // The Arrow used to access the function, use double colon print $ xxoo-> staticFunc (); print $ xxoo: $ staticProperty; // if you do not use an instance, add the double colon print :: staticFunc (); print A: constValue; // Add the dollar sign print A: $ staticProperty to the static attribute; // inherit class Aclass B extends A {// overwrite the attributes of the parent class public $ property = "covered-properties \ n "; // override the static property static public $ staitcProperty = "covered-staitcProperties \ n" of the parent class; // override the function public function func () of the parent class () {// access your attributes print $ this-> property; // access the static attributes inherited from the parent class print self: $ staticProperty; // access your own (static) function print $ this-> staticFunc (); // The print parent: func ();} function that forces the specified access to the parent class (instead of its own ();} // override the static public function staticFunc () of the parent class. {// because no $ this exists, use self to access the static attribute print self: $ staitcProperty ;}} // run the above example $ xxoo = new B; $ xxoo-> func (); B: staticFunc ();

Summary:
Arrow: Accessing attributes and (static) functions through instances
Double Colon: by class name orself,parent,staticKeyword, access constant, static attribute, static function

Http://php.net/manual/zh/language.oop...
PHP5.3 addedStatic binding laterFunction, and double colons andstaticThe keyword is related. I am learning this .....

mysqli::commitThis is not the case,phpThis indicates in the document thatcommitYesmysqliA member method of the object insteadmysqliStatic Method of this class

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.