2014-02-09 173 views
0

好吧,所以我做了一個新的登錄/註冊的事情,我有錯誤prety快速任何人都可以幫助我什麼是錯的請嗎?即時通訊看教程,並做這個cuz即時通訊新的PHP和它的作品一切正常的人,使這個..config.php註冊/登錄系統未定義的索引:配置

我得到的錯誤:注意:未定義的索引:配置在C:\ xampp \ htdocs \ loginsistem \ \班CONFIG.PHP第5行

我的init.php

<?php 
session_start(); 

$GLOBALS ['confg'] = array(
    'mysql' => array(
     'host' => '127.0.0.1', 
     'username' => 'root', 
     'password' => '', 
     'db' => 'lr' 
    ), 
    'remember' => array(
     'cookie_name' => 'hash', 
     'cookie_expiry' => 604800 
    ), 
    'session' => array(
     'session_name' => 'user' 
    ) 
); 

spl_autoload_register(function($class) { 
    require_once 'classes/' . $class . '.php'; 

}); 

require_once 'functions/sanitize.php'; 
?> 

這裏是我的sanitize.php

<?php 
function escape($string) { 
    return htmlentities($string, ENT_QUOTES, 'UTF-8');  
} 
?> 

我index.php文件

<?php 
require_once 'core/init.php'; 

echo Config::get('mysql/host'); //127.0.0.1 
?> 

和config.php文件

<?php 
class Config { 
    public static function get($path = null) { 
     if($path) { 
      $config = $GLOBALS['config']; 
      $path = explode('/', $path); 

      foreach ($path as $bit) { 
       if(isset($config[$bit])) { 
        $config = $config[$bit]; 
       } 
      } 
      return $config; 
     } 
    } 
} 
?> 
+2

你在你的init.php中有拼寫錯誤的配置 – Tims

回答

2

你做了一個微小的失誤,看看你的init.php:

$GLOBALS ['confg'] = array(

它應該是 '配置',而不是'confg';-)

+1

aaaaa thx :) thx很多 – lenart95

0

你在init.php中有confg錯誤

$GLOBALS ['config'] = array(

config.php第5行提示該問題與數組有關。

+0

ty :)非常多!! – lenart95

+0

@Francodi擊敗我:) – malta