0

パスワードの機密情報を別の .php ファイルに保存しようとしています。そのファイルを別のphpファイルに含めることができます(php2.phpと呼びます)

問題は、php1.php で使用しようとしているコードが、php2.php ページで指定された変数をエコーし​​たくないことです。配列の外側のどこでも変数をエコーでき、問題なく表示されます。私はPHPを学び始めているので、それは単なる構文エラーだと確信しています。

どんな助けでも大歓迎です!ご覧いただきありがとうございます。

編集:アップデート!

これは、私が作業しようとしているコードの全ページで、64行目でエラーが発生しています。

    <?php

        require_once 'login.php';


        // dota2 api key (you can get_info it here - http://steamcommunity.com/dev/apikey)
        $APIkey;

        //The language to retrieve results in (see http://en.wikipedia.org/wiki/ISO_639-1 for the language codes (first two characters) and http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for the country codes (last two characters))
        define ('LANGUAGE', 'en_us');

        error_reporting(0);

        set_time_limit(0);

        /**
         * Basic class with system's configuration data
         */
        class LoginInfo {
            /**
             * Configuration data
             * @access private
             * @static
             * @var array
             */

                private static $_data = array(
                    'APIkey'  => '',
                    'db_user' => '',
                    'db_pass' => '',
                    'db_host' => '',
                    'db_name' => '',
                    'db_table_prefix' => ''
                );

                public static function SetVar ($APIkey, $dbuser, $dbpass, $dbhost, $dbname, $Prefix = null){
                    self:: $_data['APIkey']  = $APIkey;
                    self:: $_data['db_user'] = $dbuser;
                    self:: $_data['db_pass'] = $dbpass;
                    self:: $_data['db_host'] = $dbhost;
                    self:: $_data['db_name'] = $dbname;
                    if ($Prefix === null){
                        self::$_data['db_table_prefix'] = '';
                    }else{
                        self::$_data['db_table_prefix'] = $Prefix;
                    }
                }

                public static function GetInfo(){
                    return self::$_data;
                }


            /**
             * Private construct to avoid object initializing
             * @access private
             */
            private function __construct() {}
            public static function init() {
                self::$_data['base_path'] = dirname(__FILE__).DIRECTORY_SEPARATOR.'includes';
                $db = db::obtain(echo LoginInfo::GetInfo()['db_user'], echo LoginInfo::GetInfo()['db_pass'], echo LoginInfo::GetInfo()['db_host'], echo LoginInfo::GetInfo()['db_name'], echo LoginInfo::GetInfo()['db_user']);
                if (!$db->connect_pdo()) {
                    die();
                };
            }
            /**
             * Get configuration parameter by key
             * @param string $key data-array key
             * @return null
             */
            public static function get($key) {
                if(isset(self::$_data[$key])) {
                    return self::$_data[$key];
                }
                return null;
            }
        }

        config::init();

        function __autoload($class) {
            scan(config::get('base_path'), $class);
        }

        function scan($path = '.', $class) {
            $ignore = array('.', '..');
            $dh = opendir($path);
            while(false !== ($file = readdir($dh))){
                if(!in_array($file, $ignore)) {
                    if(is_dir($path.DIRECTORY_SEPARATOR.$file)) {
                        scan($path.DIRECTORY_SEPARATOR.$file, $class);
                    }
                    else {
                        if ($file === 'class.'.$class.'.php') {
                            require_once($path.DIRECTORY_SEPARATOR.$file);
                            return;
                        }
                    }
                }
            }
            closedir($dh);
        }
?>
4

2 に答える 2