I'm trying to import some variables from a PHP script. It seems simple but I cannot get it to work.
The script contains some global variables like that:
$server_hostname = "localhost";
$server_database = "kimai";
$server_username = "root";
$server_password = "";
$server_conn = "mysql";
$server_type = "";
$server_prefix = "kimai_";
$language = "en";
$password_salt = "7c0wFhYHHnK5hJsNI9Coo";
Then in my script, I would like to access these variables, so I've done:
require_once 'includes/autoconf.php';
var_dump($server_hostname);
But this just outputs NULL. I've also tried:
require_once 'includes/autoconf.php';
global $server_hostname;
var_dump($server_hostname);
but still not working.
I've added some echo
statements in the "autoconf.php" file so I know that it's being loaded.
Any idea how I could access these variables?
It turns out the file was included somewhere else in the application so when I was calling require_once
, the file was not being included at all. I changed it to just require
and now it works.