Re: classes v. functions

From: Date: Sat, 19 Jul 2003 09:59:51 +0000
Subject: Re: classes v. functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155875@lists.php.net to get a copy of this message
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']; } function thing_put($stuff, $res=NULL) { if (is_null($res)) $res = $GLOBALS['thing_resource']; $GLOBALS['thing_stuff'][$res] = $stuff; } function thing_get($stuff, $res=NULL) { if (is_null($res)) $res = $GLOBALS['thing_resource']; return $GLOBALS['thing_stuff'][$res]; } Because there is no constraint to be more OO like in Java it doesnt makes sense. And this way you are more flexible. bg Sam

« previous php.general (#155875) next »