Hei,
Jeg har akkurat begynt med OOP. og har fått en error jeg ikke greier å finne ut av desverre.
localhost/development/index.php gir følgende feilmelding.
Notice: Undefined index: config in /Applications/XAMPP/xamppfiles/htdocs/Development/classes/Config.php on line 5
Under ligger filene mine. Noen her som greier å spotte feilen min?
Config.php
index.php
init.php
sanitize.php
Tusen takk til de som gidder å ta en titt
Jeg har akkurat begynt med OOP. og har fått en error jeg ikke greier å finne ut av desverre.
localhost/development/index.php gir følgende feilmelding.
Notice: Undefined index: config in /Applications/XAMPP/xamppfiles/htdocs/Development/classes/Config.php on line 5
Under ligger filene mine. Noen her som greier å spotte feilen min?
Config.php
Kode
<?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; } return false; } }
Kode
<?php require_once 'core/init.php'; echo Config::get('mysql/host'); // 127.0.0.1
Kode
<?php session_start(); $GlOBALS['config'] = array( 'mysql' => array( 'host' => '127.0.0.1', 'username' => 'root', 'password' => 'MG6250', 'db' => "lr" ), 'remember' => array( 'cookie_name' => 'hash', 'cookie_expiry' => 86400 ), 'session' => array( 'session_name' => 'user' ) ); spl_autoload_register(function($class) { require_once 'classes/'.$class.'.php'; }); require_once 'functions/sanitize.php';
Kode
<?php function escape($string) { return htmlentities($string, ENT_QUOTES, 'UTF-8'); }