我有一個其中有此代碼的形式顯示的值,從而爲我從一個類檢查字段我可以重複的誤差:不從陣列
<?php if(isset($_POST['send'])){
$new_user = new Register();
$new_user->check_required_fields($_POST);
$new_user->display_errors();
}
?>
和類是:
<?php
class Register extends Database
{
public $fname;
public $lname;
public $uname;
public $email;
public $pass1;
public $pass2;
public $year;
public $month;
public $day;
public $required_array;
public $error;
public $errors = array();
public function check_required_fields($required_array)
{
if(in_array('', $required_array)) {
$errors[] = "One or more fields are missing";
//var_dump($errors);
}
else
{
$errors[] = "All fields are ok";
$this->fname = $required_array['fname'];
$this->lname = $required_array['lname'];
$this->uname = $required_array['lname'];
$this->email = $required_array['email'];
$this->pass1 = $required_array['pass1'];
$this->pass2 = $required_array['pass2'];
$this->year = $required_array['year'];
$this->month = $required_array['month'];
$this->day = $required_array['day'];
}
}
public function display_errors ($errors)
{
foreach ($errors as $error){
echo $error;
}
}
出於某種原因,它不會顯示$ errors數組,我不知道爲什麼?我會很樂意提供任何幫助,謝謝。
我不認爲大膽的標記在代碼塊內工作:) – fncomp
@Josh乍一看,我認爲這些是C指針。爬行。 –
@Stanislav我想它會指向指針,但那麼右側會做什麼? – fncomp