php3-list | 2000051
Date: 05/09/00
- Next message: Mike Alexander Sauvain: "Re: [PHP3] php and ssh ?"
- Previous message: Simon Swain: "[PHP3] Regex + function"
- In reply to: Rajani Iyer: "[PHP3] encapsulation in php..."
- Next in thread: Michael Dearman: "Re: [PHP3] encapsulation in php..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <20000508163734.422.qmail <email protected>>,
rajani_21 <email protected> (Rajani Iyer) wrote:
> <?
> class Cart
> {
> private :
> var $owner;
> function set_owner(name){
> $this->owner = name;
> }
>
> }
>
> My_cart = new Cart
> Mycart->set_owner("Rajani");
>
> /* A statement like this should report an error */
> Mycart->owner = "Rajani"
>
> ?>
>
> Only the class functions should be allowed to
> manipulate the values of the variables.
>
> But i tried declaring the scope of the variable as
> private in php as above. But gives me error.
>
> I want a soln for this badly. pl help...
There is no way to do this in PHP, short of using PHP classes and your own
functions to create your own object system.
The above example, by the way, is a perfect example of overuse of
private. If you're going to provide a set function anyway, and you are
not going to have any operator over-loading, why are you making it private
in the first place?
PS I assume you meant to write public: in front of set_owner.
Provide a real example of why you really need private:
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Mike Alexander Sauvain: "Re: [PHP3] php and ssh ?"
- Previous message: Simon Swain: "[PHP3] Regex + function"
- In reply to: Rajani Iyer: "[PHP3] encapsulation in php..."
- Next in thread: Michael Dearman: "Re: [PHP3] encapsulation in php..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

