*update example
have read some articles and from php.net . But still having a problem to understand $this on 'this' example. I understand what is the basic used for .
Let's assume , i have a function that at the end is like this return $this; //nothing come after $this
what is the $this (at the end of the method to) refer to ? how could i check/echo-ing what the $this is
public function check($source, $items = array()){
foreach ($items as $item => $rules) {
foreach($rules as $rule => $rule_value){
$value = trim($source[$item]);
$item = escape($item);
if($rule === 'required' && empty($value)) {
$this->addError("{$item} is required");
} else if(!empty($value)) {
switch($rule) {
case 'min':
if(strlen($value) < $rule_value ) {
$this->addError("{$item} must be a minimum of {$rule_value} characters");
}
break;
case 'max':
if(strlen($value) > $rule_value ) {
$this->addError("{$item} must be a maximum of {$rule_value} characters");
}
break;
}
}
}
}
if(empty($this->_errors)) {
$this->_passed= true;
}
return $this;
}
*this code is part of register and validation class. But the point is still what the $this at the end refering to . Thanks