NYCPHP Meetup

NYPHP.org

[nycphp-talk] oo php

David Mintz vtbludgeon at gmail.com
Fri Jun 12 13:08:19 EDT 2009


On Fri, Jun 12, 2009 at 8:24 AM, Greg Rundlett (freephile) <
greg at freephile.com> wrote:

> Assuming the class definition is in memory b/c the defining file is loaded
> (require, include, auto-load),
> you can call the method by either:
> a) instantiating an object instance of the class and then calling the
> method
> b) calling the method statically (having no object).
> See the manual for an example:
> http://us.php.net/manual/en/language.oop5.basic.php
>

It looks like Michele's original snippet had the method marked as private.
That means by definition that the method can only be called from within the
class itself -- $this->somePrivateMethod()

As for static vs instance methods, I believe the best PHP5 practice is to
mark a method as static if you intend to call it statically, ditto for
instance methods, i.e., don't make them static. Offhand I forget which
transgressions are fatal and which are warnings, but I think the best
practice is well established.

-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090612/acf48fbe/attachment.html>


More information about the talk mailing list