'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();
第一種寫法會抓不到值, 第二種則可以
想不太通原因, 求大大解答, 謝謝!
--
推
12/24 10:39,
12/24 10:39
→
12/24 11:18,
12/24 11:18
→
12/24 12:30,
12/24 12:30
推
12/24 12:41,
12/24 12:41
推
12/24 16:05,
12/24 16:05
→
12/24 19:11,
12/24 19:11
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.217.117.113
※ 文章網址: http://www.ptt.cc/bbs/PHP/M.1403654276.A.4A9.html
推
06/25 10:38, , 1F
06/25 10:38, 1F
→
06/25 10:39, , 2F
06/25 10:39, 2F
推
06/25 10:41, , 3F
06/25 10:41, 3F
→
06/25 12:16, , 4F
06/25 12:16, 4F
→
06/25 12:41, , 5F
06/25 12:41, 5F
→
06/26 02:06, , 6F
06/26 02:06, 6F
→
06/26 07:31, , 7F
06/26 07:31, 7F
→
06/26 07:32, , 8F
06/26 07:32, 8F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章