0
我有一些麻煩試圖將我的公共類中的$_POST
值設置爲屬性。
class Sector
{
private $sectorName;
private $sectorInfo;
private $sectorCategory;
private $errors;
private $token;
private $config;
public function __constructor()
{
$this->errors = array();
$this->token = $_POST['token'];
$this->sectorName = $_POST['secName'];
$this->sectorInfo = $_POST['secInfo'];
$this->sectorCategory = $_POST['secCat'];
$this->config = parse_ini_file('config.ini');
}
的問題是,當我檢查,如果$this->sectorName
是空的,它總是返回true
。 但是,當我檢查$_POST['secName']
是否爲空時,它將返回false
。
編輯:這是我檢查,如果該屬性是空的功能和error_handler
功能
public function show_errors()
{
echo "Errores: ";
foreach($this->errors as $key => $value)
echo $value . "<br/>";
}
public function valid_data()
{
if (empty($this->sectorName))
{
$this->errors [] = "Datos incorrectos";
}
return count($this->errors)? 0 : 1;
}
嗯,var_dump $ _POST請 – 2013-05-12 16:33:03