Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: robert@xxxxxxxxxxxxx (Robert Cummings)
- Date: Tue, 09 Oct 2007 11:29:53 -0400
On Tue, 2007-10-09 at 09:12 -0400, Nathan Nobbe wrote:
On 10/7/07, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
Nothing brittle at all about PHP4 code. I can completely screw
up any PHP5 code you send my way too.
ok;
without modifying this class, set the value of $someInt to a value
greater than
100 or less than 0.
class TryToViolateEncapsulation {
private $someInt = 0;
public function getSomeInt() {
return $this->someInt;
}
public function setSomeInt($someInt) {
$success = false; // assume failure
$someInt = (int) $someInt;
if($this->isValid($someInt)) {
$this->someInt = $someInt;
$success = true;
}
return $success;
}
private function isValid($someInt) {
$isValid = true;
if($someInt < 0 || $someInt > 100) {
$isValid = false;
}
return $isValid;
}
}
$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.
--
............................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
............................................................
.
- Follow-Ups:
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: Larry Garfield
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Andrew Ballard"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Christoph Boget"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- References:
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Tony Marston"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Tony Marston"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Tony Marston"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: Robert Cummings
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: Robert Cummings
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- From: "Nathan Nobbe"
- Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- Prev by Date: Re: [PHP] How to format CLI tabular data?
- Next by Date: Re: [PHP] Chmod a Directory
- Previous by thread: Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- Next by thread: Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- Index(es):