How to use the function within the class??
class UserRegister{
public $password = '';
public function escape($val)
{
return mysql_real_escape_string($val);
}
public function setPassword($val)
{
$this->password = $val;
$val = escape($this->password);
$this->password = $val;
}
public function getPassword()
{
echo $this->password;
}
}
$obj = new UserRegister;
echo $obj->setPassword("dsadsadasdas'das");
echo $obj->getPassword();
But it prompt call to undefined function escape(). How can I apply escape()
which is return mysql_real_escape_string() to setPassword? I want to let mysql_real_escape_string filter it before it set to $password.