Re: [請益] 請問一下這個operator是什麼?

看板PHP作者 (Flash)時間9年前 (2014/07/16 13:01), 9年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
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; : : "->" : : 請問大大們,這個是什麼運算子啊? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.242.161.16 ※ 文章網址: http://www.ptt.cc/bbs/PHP/M.1405486916.A.202.html ※ 編輯: tanson (210.242.161.16), 07/16/2014 13:03:04
文章代碼(AID): #1JnWT482 (PHP)
文章代碼(AID): #1JnWT482 (PHP)