看板 PHP 關於我們 聯絡資訊
'config.php' $_SESSION['ROOT'] = 'www.test.com.tw'; ## 第一種寫法 ## require_once('config.php'); class test{ public $rootUrl = $_SESSION['ROOT']; function __construct(){ } function getRoot(){ return $this->rootUrl; } } ## 第二種寫法 ## require_once('config.php'); class test{ public $rootUrl; function __construct(){ $this->rootUrl = $_SESSION['ROOT']; } function getRoot(){ return $this->rootUrl; } } $test = new test(); $test->getRoot(); 第一種寫法會抓不到值, 第二種則可以 想不太通原因, 求大大解答, 謝謝! --
Non:If 薪水<28K Then 離職12/24 10:39
maddman:else 跳槽 12/24 11:18
tsming:goto 買樂透XD12/24 12:30
YUKIKASE:應該加入 #include"把上董事長女兒.h" 這個函式庫 :p12/24 12:41
smallworld:樓上有.h沒有lib也是夢一場 include大家都會阿 12/24 16:05
PUTOUCHANG:Error: invalid path12/24 19:11
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.217.117.113 ※ 文章網址: http://www.ptt.cc/bbs/PHP/M.1403654276.A.4A9.html
meteorsok:google: php properties, 第一段 06/25 10:38
meteorsok:前略...this initialization must be a constant value 06/25 10:39
meteorsok:你第一種應該會報錯才對,寫法錯誤。 06/25 10:41
MOONRAKER:不會改的東東為什麼要放在$_SESSION裡面… 06/25 12:16
up9cloud:debug時請先 ini_set('display_errors', 'On'); 06/26 02:06
m7m123d:謝謝提供關鍵字和相關資料 06/26 07:31
m7m123d:除錯有開, 是不懂為什麼這樣有bug, 算是對class不夠了解 06/26 07:32