06-17-2009, 08:31 PM
|
#13 (permalink)
|
|
how quixotic are you?
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
|
Ok, here's a little String class I just whipped up:
PHP Code:
class String { private $string;
public function __construct($data=''){$this->string = $data;} public function __toString(){return $this->string;} public function set($data=''){$this->string=$data;return $this;} public function append($data=''){$this->string.=$data;return $this;} public function prepend($data=''){$this->string=($data.$this->string);return $this;} public function lowercase(){$this->string=strtolower($this->string);return $this;} public function uppercase(){$this->string=strtoupper($this->string);return $this;} }
And here is and example of using it:
PHP Code:
$test = new String('This is Quixotic!'); echo $test; echo '<br />';
echo $test->lowercase()->append(' Wow!'); echo '<br />';
echo $test->prepend('Very Nice! '); echo '<br />';
echo $test->set('Starting over.');
That would output this:
Code:
This is Quixotic!
this is quixotic! Wow!
Very Nice! this is quixotic! Wow!
Starting over.
|
|
|
|