Accessing current class through $this-> from a function called statically. [PHP]
- by MQA
This feels a bit messy, but I'd like to be able to call a member function statically, yet have the rest of the class behave normally...
Example:
<?php
class Email
{
private $username = 'user';
private $password = 'password';
private $from = '[email protected]';
public $to;
public function SendMsg($to, $body)
{
if (isset($this))
$email &= $this;
else
$email = new Email();
$email->to = $to;
// Rest of function...
}
}
Email::SendMsg('[email protected]');
How best do I allow the static function call in this example?
Thanks!