비밀번호에 민감한 정보를 별도의 .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);
}
?>
오, 지금 당신의 질문을 이해 :
하지만 당신은 위의 호출 형식을 지원하지 않는 PHP의 이전 버전을 사용하는 경우
. – Kiruse필자는 php echo $ variable?>가 문제이며 echo $ variable을 사용하여 시도했지만 " '안에 싫어합니다. – Tandar