I imagine this is fairly simple and one I should be able to get but I am having trouble with it. I can't seem to find an answer for this anywhere.
Consider the scenario: I have two files (we'll call them index.php and global.php). I am properly referencing the require_once()
file.
Index.php:
<?php
require_once('./global.php');
$database = new database();
echo $database->dbname;
?>
Global.php:
<?php
class database {
public $dbname = 'jdoe';
}
?>
This does not output 'jdoe' on the index.php page. However...if I place the following into global.php, it works:
<?php
class database {
public $dbname = 'jdoe';
}
$database = new database();
echo $database->dbname;
?>