What does $this generally mean in PHP? -
i new php, kind of confused seeing these different operators day. here code came across when watching video tutorail, i'd appreciate if explain little bit:
class email extends ci_controller { function __construct() { parent::__construct(); } function index() { $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'username@gmail.com', 'smtp_pass' =>'password', ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('username@gmail.com', 'jerry'); $this->email->to('username@gmail.com'); $this->email->subject('this email test'); $this->email->message('this test message!'); if($this->email->send()) { echo 'your email sent'; } else { show_error($this->email->print_debugger()); } } ...
in case, function index part of class. index function accessing other objects member values of same class. in order access member values, have use pseudo-variable $this. $this refers object in.
for exmaple:
$this->email->subject('this email test');
translated: call "subject function" email object, member of object.
Comments
Post a Comment