Re: Re: classes v. functions

From: Date: Sat, 19 Jul 2003 14:30:16 +0000
Subject: Re: Re: classes v. functions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-155887@lists.php.net to get a copy of this message
Sam Baum <idsam@gmx.de> wrote: > Hi, > > am Friday 18 July 2003 23:08 schrieb Andu: > > > This may show my ignorance or my refusal to take for granted something I > > don't fully understand but I have a hard time figuring out the advantage > > of using classes as opposed to just functions. I am certainly new to php > > and at first sight classes seemed to cut a lot of corners but so do > > functions (with which I have more experience). The more I read about > > classes the deeper the confusion. Anyone can enlighten me? > > Im programming for a few years now in PHP. After trying to use classes i > dont see their point either. In most cases if i need a class-like structure > i do something like this: > > function thing_new() { > return ++$GLOBALS['thing_resource']; > } The biggest thing classes do is resolve name space issues, even with this method you have namespace issues with your function name and your variables. This rather effects a lot of people who create libraries to share with. A big downfall with classes, however is there speed. Benchmarking a function call vs. a class->method call, results in a significant difference and even more if your using a lot of classes. In general, I only use small and nicely bundled classes that don't have to do a lot of work, ie authentication, session. > > Because there is no constraint to be more OO like in Java it doesnt makes > sense. And this way you are more flexible. And besides php wasn't designed/developed to be an OO language. Curt.

« previous php.general (#155887) next »