Can anyone tell the difference between mysqli->commit and mysqli::commit?
The header in this page is mysqli::commit, but in examples they use mysqli->commit.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
->is used when referring to a member of an object.::is the Scope Resolution Operator and is used to refer to a static member of a Class.Consider the following class:
You would call the function
buzz()using->:But would use
::to call the functonfizz(), as it is a static member (a member which doesn’t require an instance of the class to be called):Also, while we are talking about the difference between static members versus instantiated members, you cannot use
$thisto refer to the current instance within static members. You useselfinstead (no leading$) which refers to the current class, orparentif you want to refer to the parent class, or if you have the pleasure of working with PHP 5.3.0,static(which allows for late static binding).The documentation uses
::to refer to a function inside a class as the class name in the header is not an instance of the class. Still using the same example, a documentation entry referring to the functionbuzz()would use the following header:But unless the documentation specifies it’s a static member, you will need to use
->on an instance to call it: