11-17-2008, 03:44 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
php Code:
class Welcome { private $newUser; private $myName; public function __construct($name) { if(is_string($name)) { $this-> newUser = $name; } else throw new Exception ('Parameter only supports string.'); } public function setName ($name) { if(is_string($name)) { $this-> myName = $name; } else throw new Exception ('Parameter only supports string.'); } public function getWelcome () { $string = 'Welcome dear ' . $this-> newUser . ' to TalkPHP. Hope you enjoy the site!<br />Kind regards, ' . $this-> myName; return $string; } }
PHP Code:
$msg = new Welcome('Dal'); $msg->setName('Tanax'); echo $msg->getWelcome();
Code:
Welcome dear Dal to TalkPHP. Hope you enjoy the site!
Kind regards, Tanax
__________________
|
|
|
|