我有类文件:
class Settings
{
public $siteName;
public $siteAddr;
public $dbUrl;
public $dbName;
public $dbPass;
public function __construct()
{
$siteName = 'Welcome';
$siteAddr = 'http://site.com';
$dbUrl = 'test';
$dbName = 'base';
$dbPass = '123';
}
}
尝试在其他文件中使用它:
require_once('settings.php');
$cfg = new Settings();
var_dump($cfg); // <--- everywhere is null...
为什么它只包含空值?