안녕하세요 저는 Denis이고 저는 PHP를 처음 사용합니다. 우리 아빠는 PHP 개발자이지만 혼자서하고 싶습니다. 나는 11 살이야! :) 정의되지 않은 변수 오류
나는 내 PHP는 일에 대한 설치 프로그램을 만들어이 오류 얻을 : 그것은 실패를이 부분의Notice: Undefined variable: config in \path\to\core.php on line 20
:
$system['home_url'] = "".$config['home']['url']."";
을하지만이 포함 된 경우 어떻게 실패 할 수 있습니다 config 파일을 앞에두고이 변수는 정의되지 않았습니다!
은 내가 그랬어 : require('config.php');
config.php 파일의 코드는 다음과 같습니다
$config['home']['url'] = "http://localhost/";
것은 내가 변수를 잘 사용하고 있는가? 나는 모든 인터넷을 검색했고 단지 global
을 사용하여 솔루션을 찾았지만 어떻게 작동하는지 실제로 알지 못합니다 ..
안녕! 사용 사장님 isset($config['home']['url'])
전에 감사 :)))
EDIT-- Core.PHP
<?PHP
/*=======================================================================
| #######################################################################
| This program is free software: you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation, either version 3 of the License, or
| (at your option) any later version.
| #######################################################################
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
\======================================================================*/
require('config.php');
$system['home_url'] = "".$config['home']['url']."";
$system['updates_enabled'] = "".$config['updates']['enabled']."";
$system['update_url'] = "".$config['update']['url']."";
$system['language'] = $config['language'];
$system['favicon'] = "".$config['favicon']."";
$system['maintenance_status'] = "".$config['maintenance']['status']."";
$system['version'] = "".$config['version']."";
$system['master_user'] = "".$config['master']['user']."";
$system['master_password'] = "".$config['master']['password']."";
$system['config_path'] = "config.php";
/*====================================================================*/
$site['name'] = "".$config['site']['name']."";
$site['desc'] = "".$config['site']['desc']."";
/*====================================================================*/
$cloud_panel['reload_time'] = "".$config['reload']['time']."";
/*====================================================================*/
require "".$system['home_url']."lang/lang_".$system['language'].".php";
/*====================================================================*/
$template['id'] = "".$config['template']['id']."";
$template['webgallery_type'] = "".$config['webgallery']['type']."";
$template['webgallery_url'] = "".$config['webgallery']['url']."";
/*====================================================================*/
if(isset($_GET['help'])) { header('Location: '.$system['home_url'].'help.php'); }
/*====================================================================*/
if ($template['webgallery_type'] == 1) { $template['my_webgallery'] = "".$system['home_url']."cdn/web-gallery"; } else { $template['my_webgallery'] = $template['webgallery_url']; }
/*====================================================================*/
?>
config.php에이
<?PHP
/*=======================================================================
| #######################################################################
| This program is free software: you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation, either version 3 of the License, or
| (at your option) any later version.
| #######################################################################
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
\======================================================================*/
$config['site']['name'] = "heya";
$config['site']['desc'] = "heya";
$config['home']['url'] = "http://localhost/";
$config['updates']['enabled'] = "1";
$config['update']['url'] = "http://localhost/update";
$config['language'] = "es";
$config['favicon'] = "favicon.ico";
$config['maintenance']['status'] = "1";
$config['reload']['time'] = "10";
$config['version'] = "1.3.4";
$config['master']['user'] = "heya";
$config['master']['password'] = "heya";
$config['template']['id'] = "9";
$config['webgallery']['type'] = "1";
$config['webgallery']['url'] = "heya";
?>
입니다 사용할 수 있습니다 배열? 여기에 다차원 배열이 있기 때문에 –
config.php와 동일한 디렉토리에 스크립트 파일이 있습니까? – SaidbakR
범위 지정 문제가 있습니까? 귀하의 전체 코드를 보여주십시오 (적어도 관련성이 있음). 또한 :' ""$ var. ""'는 무의미합니다. 빈 문자열을 변수에 연결하여 빈 문자열을 만듭니다. 그냥'$ var'을하십시오. – deceze