Reply to Re: Parent Objects

Your name:

Reply:


Posted by Toby Inkster on 01/13/07 10:05

Sanders Kaufman wrote:

> When I use a class's methods and such, I've been using "->".
> But it seems like this "::" is used the same way.

Using '::' you can call a classes methods, constants and static functions
(here's the key part) without instantiating an object of that class.

Example:

<?php
include "Widget.class.php";
echo Widget::FOO;
?>

Versus:

<?php
include "Widget.class.php";
$my_widget = new Widget();
echo $my_widget->FOO;
?>

Another example:

<?php
class Widget
{
function exist ()
{
return isset($this);
}
}
$my_widget = new Widget();
$my_widget->exist(); // true
Widget::exist(); // false
?>

That is, '->' forces a function to run on a specific object, whereas '::'
runs the function without the object instance (i.e. '$this' is undefined).

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

[Back to original 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

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