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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to