Il sorgente della classe YIWBirthday:
<?php
class YIWbirthday
{
protected $hb;
protected $ty;
protected $yiw;
public function __construct()
{
$this->hb = "Happy birthday";
$this->ty = " to you";
$this->yiw = "Your Inspiration Web";
}
private function Is_YIW_birthday()
{
if(date("j") == 30 AND date("m") == 4)
{
return TRUE;
}
else
{
return FALSE;
}
}
public function Title()
{
if($this->Is_YIW_birthday())
{
$title = "Oggi " . $this->yiw . " compie ";
$year = date("Y") - 2009;
if($year > 1)
{
$last_letter = "i";
}
else
{
$last_letter = "o";
}
$title .= $year . " ann$last_letter";
return '<h1>' . $title . '</h1>';
}
}
public function Greeting()
{
if($this->Is_YIW_birthday())
{
$greeting = "";
for ($i = 0; $i < 2; $i++)
{
$greeting .= $this->hb . $this->ty . '<br />';
}
$greeting .= $this->hb . ' ' . $this->yiw . '<br />';
$greeting .= $this->hb . $this->ty;
return $greeting;
}
}
}
$greeting = new YIWbirthday();
echo $greeting->Title();
echo $greeting->Greeting();
?>
<br /><br />
<strong>Il sorgente della classe YIWBirthday:</strong>
<br /><br />
<?php
show_source('greeting.php');
?>