Posted by Justin Koivisto on 08/05/05 17:02
mjs7231 wrote:
> What is the difference between "::" and "->" when using classes?
>
> It always hard to find documentation for something that i only a
> symbol. :)
:: calls a class method statically - that is, you don't have to have an
instance of the class.
-> calls a class method as part of an object.
If you have something like:
require 'MyClass.php';
$x = new MyClass();
Then you'd use $x->method() to call the methods in the class as part of
the instance/object.
You can also do something like:
require 'MyClass.php';
$res = MyClass::isError($obj);
In most cases, static methods need a parameter, unless they are simply
output routines.
HTH
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|