我是很新的面向对象的PHP和尝试一些基本的例子来获得良好的手放在了PHP。 我已经在上面我正努力学习异常处理,当年龄大于20,但无法正常工作产生异常错误信息简单〔实施例。
<?php
interface read_methods
{
public function read_age($age);
}
abstract class person
{
var $gender;
var $animal;
var $birds;
abstract function group($group);
function people($value)
{
$this->gender=$value;
}
function animals($value)
{
$this->animal=$value;
}
function bird($value)
{
$this->birds=$value;
}
}
class behaviour extends person implements read_methods
{
var $nonhuman;
function get_all()
{
return $this->people();
return $this->animals();
return $this->bird();
}
function non_human($nonhuman)
{
return $this->alien=$nonhuman;
}
function read_age($age)
{
try {
$this->age=$age;
}
catch(Exception $e)
{
if ($age > 20)
{
throw new Exeption("age exceeds",$age, $e->getMessage());
}
}
}
function group($group)
{
return $this->group=$group;
}
}
$doerte=new behaviour();
$doerte ->people(array('male','female'));
$doerte ->animals(array('fish','whale'));
$doerte ->bird(array('parrot','crow'));
$doerte->non_human('alien');
$doerte->read_age('23');
$doerte->group('living_things');
//$doerte->__autoload();
print_r($doerte);
?>