You are here: Re: PHP Classes :: & -> « PHP Programming Language « IT news, forums, messages
Re: PHP Classes :: & ->

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация