1

So I'm trying to display an array in PHP. This is my index.php

<?php
require_once 'core/init.php';
echo GET::get('mysql/host');
?>

My Config.php

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

And finally my init.php

<?php
session_start();


$GLOBALS['config'] = array(
    'mysql' => array(
    'host' => '127.0.0.1',
    'username' => 'root',
    'password' => 'wayne123',
    'db' => 's'
    ), 
'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';

?>

When I go to index.php in the browser I don't see the array, which is weird since I'm pretty sure everything is fine. Could this be a file location issue? How can I tell what the error is? Since All I get is a blank page. Any ideas would be wonderful

csharpwinphonexaml
  • 3,659
  • 10
  • 32
  • 63
  • 3
    use `var_dump()` instead of `echo` – Loïc Apr 28 '14 at 15:51
  • Use `var_dump()` instead of `echo` to get better debug information. – Halcyon Apr 28 '14 at 15:52
  • 4
    A blank page often means that your script is throwing an error but you haven't configured PHP to display error messages. That's something you need to fix before you go further; it's impossible to code properly without the aid of error messages. Here's a [brief explanation](http://stackoverflow.com/a/5680885/13508). – Álvaro González Apr 28 '14 at 15:53
  • 4
    Shouldn't `GET::get('mysql/host');` be `Config::get('mysql/host');` – Think Different Apr 28 '14 at 15:54
  • So `var_dump(GET::get('mysql/host'));` @Loïc –  Apr 28 '14 at 15:59

1 Answers1

-1

User

Config::get('mysql/host');

Instead of

GET::get('mysql/host');

in your index.php

Think Different
  • 2,815
  • 1
  • 12
  • 18
  • I think I put `GET` in there by accident. But It still isn't working anyways –  Apr 28 '14 at 15:59
  • remove the echo just call it directly as you are using `print_r` anyway – Think Different Apr 28 '14 at 15:59
  • Just read your comment and turned it on. Turns out I forgot to wrap one of the lines in an array. Post an answer and I'll accept it. @ÁlvaroG.Vicario –  Apr 28 '14 at 16:03