RE: [PHP] OOP vs procedural

From: Date: Wed, 07 May 2003 15:03:51 +0000
Subject: RE: [PHP] OOP vs procedural
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146680@lists.php.net to get a copy of this message
At 16:49 07.05.2003, Hardik Doshi spoke out and said: --------------------[snip]-------------------- >I have a question on OOP. > >What you guys are using for calling functions withing >class? I am putting functions in class and calling it >by classname::function name (place where there is no >need to create an object). Is it the correct way to >calling it? I thought there is no need to allocate >memory for the object of class. > >Please give your thoughts. --------------------[snip]-------------------- This is a valid method and used widely in other oop languages as well. Class methods that do not necessarily need an object instance (they lack a valid $this object) are called static methods. You can always call a static methods as classname::methodname(params). Differing to "real" OOP languages, PHP doesn't have the capability of declaring static class methods, you need to work this out yourself. You may always check for the $this variable; usually when it exists (isset) then the object has been called non-static. I say "usually" because if any object instance calls another class method in a static way, the $this variable will propagate into the static method - unfortunately. Hope this will change with PHP5. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#146680) next »