This question already has an answer here:
like my title says, whenever I try to use my variables from another php file, it doesn't work (Undefined variable). I did declare them in the file that I'm including. For example, I have this file called variables.php that have this in it:
<?php
$DEBUG = TRUE;
$mysqli = new mysqli("127.0.0.1", "root", "", "29185917-database");
$DEBUG_LOG_FILE = "../log";
?>
And then I have another file called debug.php that tries to use the variable 'DEBUG' but it cannot access it. Here is my debug.php file:
<?php
require_once 'variables.php';
function echo_debug(string $message)
{
if($DEBUG) {
echo $message;
}
}
?>
Whenever I try to use my function echo_debug I get the error message : Undefined variable 'DEBUG'. Any help on this problem is appreciated :).
</div>