Re: Beginner Tutorials for using CLASSES in PHP4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 09 October 2007, Robert Cummings wrote:

> $sucker = new TryToViolateEncapsulation();
> $sucker = (array)$sucker;
>
> $keys = array_keys( $sucker );
> $sucker[reset( $keys )] = 500;
>
> $sucker = serialize( (object)$sucker );
> $sucker = 'O:25:"TryToViolateEncapsulation"'.substr( $sucker, 14 );
> $sucker = unserialize( $sucker );
>
> print_r( $sucker );
>
>
>
> Maybe next time you'll have a challenge for me ;) And don't whine about
> how I achieved what I did.
>
> Cheers,
> Rob.

I've never actually thought of doing it that way, but I must say I find it an 
amusing method. :-)

That said, I stand by my earlier comment.  Never use private variables.  Ever.  
Use public or protected, but never private.  Private makes them un-extensible 
to child classes.  That's just flat out rude.

And really, there's FAR more interesting and useful pieces to OOP, PHP's style 
or otherwise, than PPP.  Interfaces are useful.  Being able to pass objects 
around to each other without performance or references dying is useful.  And 
SPL is just plain cool. :-)

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux