my favorite

2010/02/25

interface for oop

interface IUser
{
function sayHello();
}

class User implements IUser
{
private $name;

public function __construct( $name ) { 
$this->name = $name;
}

public function sayHello()
{
return 'Hello ' . $this->name;
}
}

class Creator
{
public static function Create( $name )
{
return new User( $name );
}
}

$uo = Creator::Create( 'huge' );
echo( $uo->sayHello()."\n" );

No comments:

BIO

Taipei, GuTing, Taiwan

huang47 | personal

huang47 | personal