我的zend框架2项目涉及一个在线餐厅菜单,我的代码出了问题,因为我遇到了这个错误:
Fatal error: Interface 'Pizza\Model\InputFilterAwarelnterface' not found
C:\wamp\www\pizza\module\Pizza\src\Pizza\Model\pizza.php on line 9
请帮我查一下我的代码有什么问题。 这是pizza.php文件:
<?php
namespace Pizza\Model;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterInterface;
use Zend\InputFilter\InputFilterAwareInterface;
class Pizza implements InputFilterAwarelnterface
{
public $id;
public $name;
public $ingredients;
public $smallprice;
public $bigprice;
public $familyprice;
public $partyprice;
protected $inputFilter;
public function __construct()
{
}
public function exchangeArray($data)
{
$this->id = (!empty($data['id'])) ? $data['id'] :null;
$this->name = (!empty($data['name'])) ? $data['name'] :null;
$this->ingredients = (!empty($data['ingredients'])) ? $data['ingredients'] :null;
$this->smallprice = (!empty($data['smallprice'])) ? $data['smallprice'] :null;
$this->bigprice = (!empty($data['bigprice'])) ? $data['bigprice'] :null;
$this->familyprice = (!empty($data['familyprice'])) ? $data['familyprice'] :null;
$this->partyprice = (!empty($data['partyprice'])) ? $data['partyprice'] :null;
}
public function getArrayCopy()
{
return get_object_vars($this);
}
public function setInputFilter(InputFilterInterface $inputfilter)
{
throw new \Exception("not used");
}
public function getInpunFilter()
{
if(!$this->inputFliter)
{
$inputfilter = new InputFilter();
$inputfilter->add(array('name' => 'name',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 5,
'max' =>30,),
))
)
);
$inputfilter->add(array('name' => 'ingredients',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 5,
'max' =>255,),
))
)
);
$inputfilter->add(array('name' => 'smallprice',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 5,),
),
array(
'name' => 'float',
'options' => array(
'locale' => 'en_us')
)
)
)
);
$inputfilter->add(array('name' => 'bigprice',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 5,),
),
array(
'name' => 'float',
'options' => array(
'locale' => 'en_us')
)
)
)
);
$inputfilter->add(array('name' => 'familyprice',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 5,),
),
array(
'name' => 'float',
'options' => array(
'locale' => 'en_us')
)
)
)
);
$inputfilter->add(array('name' => 'partyprice',
'required' => true,
'filters' => array('name' => 'StringTrim'),
array('name' => 'StringTags'),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 5,),
),
array(
'name' => 'float',
'options' => array(
'locale' => 'en_us')
)
)
)
);
return $this->inputFilter;
}
return $this->inputFilter;
}
}
答案 0 :(得分:2)
简单的拼写错误:
class Pizza implements InputFilterAwarelnterface
^
This character should be an 'I', not a 'l'