Hi all, i have been a fan of sitepoint for a while now.

I have come to a hard place and require a little assistance.

I have the following Class (file : headScript.php)
PHP Code:
 <?php
    
class headScript
    
{
    public function 
connection()
    {
    try
    {
    
$dbh = new PDO("mysql:host=localhost;dbname=xxx"'xxx''xxx'); // Dev
    
return $dbh;
    }
    catch(
PDOException $e)
    {
    echo 
"Error :- " $e->getMessage();
    die();
    }
    }
    public function 
headLoad()
    {
    
$cxn $this->connection()->prepare("SELECT scriptCode FROM head_scripts WHERE active != '0'");
    
$cxn->execute();
    
$cxn->setFetchMode(PDO::FETCH_ASSOC);
    while(
$row $cxn->fetch())
    {
    print 
"<script>";
    print 
$row['scriptCode'];
    print 
"</script>";
    }
    }
    }
    
?>
I'd like to remove the connection function and put this in its own file, then using namespace to pull this in. That way i have one file which can be called via namespace and i can use this function.

Am I thinking this is possible when it is not?

I have tried a few things but cant seem to get it to work.

Can anyone offer assistance?