1
namespace core;
class Entity {
private $type;
public function __construct($type, $source=null){
if($this::isValidType($type)){
$this->type = $type;
}else{
throw new Exception("'".$type."' is not a valid type of entity.");
}
}
private static function isValidType($type){
return in_array($type, array(
'Thing',
));
}
}
然後我用這個代碼:
$thing = new core\Entity('Not a Thing');
而且我希望它顯示"Not a Thing" is not a valid Type of entity
而是我得到
Fatal Error: Class 'core\Exception' not found in {root/to/my/file} on line {line}`.
我錯過了什麼嗎?
哦!嗯你是對的!謝謝。 – thingNumber2
@ thingNumber2歡迎... :) –