In A.php
I include config.php
and B.php
:
include_once("path/to/config.php");
include_once("path/to/B.php");
B.php
is generic script used by other scripts. I don't know if script, which included B.php
, also included config.php
so in B.php
there is
include_once("path/to/config.php");
The problem is that in A.php
I can read all the variables from config.php
, but in B.php
they aren't set. If I do print_r(get_included_files())
in B.php
, I can see that config.php
is included.
What is causing this? How can I properly include that config.php
so it will be available in B.php
(and other scripts included by A.php
...)?
EDIT: added scripts content.
config.php
:
<?php
$db_ip = "";
$db_login="";
$db_pass ="";
$db_port = 30050;
$db_name_hlstats = "";
$db_name_csgo = "";
$db_name_report = "";
$db_web_host = "";
$db_web_port = "3306";
$db_web_login = "";
$db_web_pass = "";
$db_web_name = "";
B.php
:
<?php
function GetServers()
{
include_once("/data/web/virtuals/93680/virtual/config/config.php");
include_once("/data/web/virtuals/93680/virtual/scripts/getPDO.php");
include_once("/data/web/virtuals/93680/virtual/scripts/PDOQuery.php");
print_r(get_included_files()); // shows config.php in included files
echo "servers.php | $db_ip:$db_port"; // variables show nothing
$pdo = getPDOConnection($db_ip, $db_login, $db_pass, $db_name_csgo, $db_port);
$query = "SELECT ...";
$result = getPDOQueryResult($pdo, $query, __FILE__, __LINE__);
$res = array();
foreach ($result as $row)
{
$res[$row["server_id"]] = $row;
}
return $res;
}