20-01-2010, 04:32 PM
Code PHP :
<?php
class Item
{
public $name;
public function __Construct( $name )
{
$this->name = $name;
}
public function __toString()
{
return $this->name;
}
}
class Character
{
public $name;
public $items = array();
public function __Construct( $name )
{
$this->name = $name;
}
public function __toString()
{
return $this->name;
}
}
$corwin = new Character("Corwin");
$corwin->items[] = new Item("Grayswandir");
print $corwin . '\'s profile';
print '';
print 'Items (' . count($corwin->items) . ')';
foreach($corwin->items AS $item):
print ' - ' . $item;
endforeach;