作者:
m7m123d ( )
2014-06-25 07:57:40'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();
第一種寫法會抓不到值, 第二種則可以
想不太通原因, 求大大解答, 謝謝!
作者: up9cloud (九天) 2014-06-26 02:06:00
debug時請先 ini_set('display_errors', 'On');