我有 config.php 文件
<?php
define(DBHOST, 'localhost');
define(DBNAME, 'new_shop_site');
define(DBUSER, 'root');
define(DBPASS, '');
?>
我尝试在 database.php 文件中获取该文件的值
database.php中 我尝试 1
<?php
class database{
include_once("config/config.php");
/*database credentials*/
private static $host = DBHOST;
private static $username = DBUSER;
private static $pass = DBPASS;
private static $dbname = DBNAME;
}
?>
然后尝试 2
<?php
include_once("config/config.php");
class database{
/*database credentials*/
private static $host = DBHOST;
private static $username = DBUSER;
private static $pass = DBPASS;
private static $dbname = DBNAME;
}
?>
但没有工作。 我怎么得到这个值?