Re: [请益] 请问一下这个operator是什么?

楼主: tanson (Flash)   2014-07-16 13:01:53
1. 一般属性设定方法
class mail
{
protected $_transport;
public function setTransport($transport)
{
$this->_transport = $transport;
}
public function getTransport()
{
return $this->_transport;
}
}
$mail = new Mail();
$mail->setTransport('smpt');
echo $mail->getTransport(); // print 'smtp'
$mail2 = new Mail();
$mail->setTransport('sendMail');
echo $mail->getTransport(); // print 'sendMail'
2. 静态属性设定方式
class mail
{
static protected $_transport;
static public function setTransport($transport)
{
self::$_transport = $transport;
}
static public function getTransport()
{
return self::$_transport;
}
}
$mail = new Mail();
$mail2 = new Mail();
mail::setTransport('smtp');
echo $mail::getTransport(); // print 'smtp'
echo $mail2::getTransport(); // print 'smtp'
mail::getTransport(); // print 'smtp'
一般使用-> 设定属性或使用方法,属性值存在该类别内
静态使用:: 设定静态的属性或方法,
属性值可以想像是该类别的全域变量,只会有一个值
※ 引述《wanzoo (Zoo)》之铭言:
: 可否请大大们示范一下用法?
: 网络上找得到的资料都有点模糊。
: 另外还有一个“::”,也是同样的东西吗?
: ※ 引述《wanzoo (Zoo)》之铭言:
: : if(!$this->PreSend()) return false;
: : return $this->PostSend();
: : } catch (phpmailerException $e) {
: : $this->mailHeader = '';
: : $this->SetError($e->getMessage());
: : if ($this->exceptions) {
: : throw $e;
: : }
: : return false;
: : "->"
: : 请问大大们,这个是什么运算子啊?

Links booklink

Contact Us: admin [ a t ] ucptt.com