Postingan lainnya
Oop error
saya mengikuti tutorial oop login dan register sudah saya ikut sama persis masih ada error, dimana kesalahan saya
<?php
class Validation{
private $_passed = false;
$_errors = array();
public function check( $items = array() ){
foreach ($items as $item => $rules) {
foreach ($rules as $rule => $rule_value) {
switch ($rule) {
case 'required':
if( trim(Input::get($item)) == false && $rule_value == true){
$this->addError(" $item wajib diisi ");
}
break;
case 'min':
if( strlen(Input::get($item)) < $rule_value ){
$this->addError(" $item minimal $rule_value karakter ");
}
break;
case 'max':
if( strlen(Input::get($item)) > $rule_value ){
$this->addError(" $item maksimal $rule_value karakter ");
}
break;
default:
break;
}
} //end first foreach
}
if(empty($this->_errors)){
$this->_passed = true;
}
return $this;
}
private function addError($error){
$this->_errors[] = $error;
}
public function errors(){
return $this->_errors;
}
public function passed(){
return $this->_passed;
}
}
?>
0
2 Jawaban:
error nya adalah Parse error: syntax error, unexpected '$_errors' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) in C:\xampp\htdocs\auth\classes\Validation.php on line 7
0
Errornya dibagian ini gan: <pre> class Validation{
private $_passed = false;
$_errors = array();
</pre> Ganti jadi seperti ini gan:
<pre> class Validation{
private $_passed = false,
$_errors = array(); // dipisah dengan koma (,) bukan titik koma (;)
</pre>
Terimakasih ...
0