For years I have done something like this:
config.php
<?php
$db = array("user" => "username", "pass" => "password");
functions.php
<?php
require_once('config.php');
function connectToDatabase() {
$dbc = new PDO($dsn, $db['user'], $db['pass']);
// Do some stuff ...
}
I've just read the PHP manual and that SHOULDNT work, but for years it has. Are there any server configurations that allow that to work?
I've just coded a new script and getting errors. The $db array is not even initialized.