Re: Beginner Tutorials for using CLASSES in PHP4

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

 



On 10/9/07, Larry Garfield <larry@xxxxxxxxxxxxxxxx> wrote:
>
> 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. :-)


i new rob would come up w/ something otherwise he wouldnt have made the
offer.
i tried to override the __sleep method to throw an exception but it had no
effect;
rob really knows php well.

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.


right; protected is only for variables that the child class would need
access to;
even children dont need access to all of their parents details.
i say; mark all member variables private and reduce the access as need be.

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. :-)


yes; SPL is really nice; though some more documentation would be great.
the articles online mostly cover basic usage examples.

-nathan

[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