如何在我的类文件中使用我的DEFINE var文件并在课堂中使用?用PHP

时间:2016-12-31 07:37:25

标签: php

我有 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;
}
?>

但没有工作。 我怎么得到这个值?

0 个答案:

没有答案