Re: [PHP] private variable in object ?? From: Richard Lynch (richard <email protected>)
Date: 12/29/00

> hi, I'm used programming OO in java.
> the variable in a class could be private. only instance of te same classe
> can directly access those variable. all other have to use functions
> like
> name = someObject.getName()
>
> I'd like to know if php uses (or is able to use) this structure because in
> this way the programmer got more control over all the things that happens
in
> a object.

Not at this time.

You can "fake it" by writing something not unlike this:

function private_foo($set = ''){
    static $foo;
    if (isset($set)){
        $foo = $set;
    }
    return $foo;
}

class bar{
    function bar(){
        private_foo();
    }

    function set_bar($new_value){
        private_foo($new_value);
    }
}

Now, bar() essentially behaves like a private $bar variable.

Disclaimer: I don't use PHP OO.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>