RE: [PHP] how to access private property?
| From: | Edward Kay | Date: | Tue, 06 Mar 2007 12:26:22 +0000 |
| Subject: | RE: [PHP] how to access private property? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249923@lists.php.net to get a copy of this message | ||
>
> Hello Everyone,
>
> [code]
> class MyClass {
> private $prop;
> }
> $obj=new MyClass;
> [/code]
>
> is there anyway to read and write MyClass->prop, except serialize
>
Not directly, that's the whole point of declaring something private. You
could use __set and __get methods in the class if you need to but I think
you need to consider your design further first.
Edward