I have 3 files in my project. For arguments sake let's called them a.php, b.php and c.php.
In a.php I have a declared variable: $sql_connection
In b.php I have declared a function: check_if_logged_in()
With these declared, I now want to be able to use the variables across my files. I have included a.php in my b.php file, and I included my b.php inside c.php.
I'd expect this all to work but for some reason b.php isn't getting $sql_connection
from a.php?
My a.php
file:
<?php
$sql_connection = mysqli_connect("localhost", "user", "password", "database");
?>
My b.php
file:
<?php
include ("a.php");
function check_if_logged_in() {
$sqlquery = mysqli_query($sql_connection, ...
}
?>
My c.php
file:
<?php
include ("b.php");
check_if_logged_in();
?>