vorrei usare una variabile globale in modo che possa usarla su diverse funzioni:
Codice PHP:
global $obj;
$obj = new Config();

function 
selectAuthor() {
    
//    $obj = new Config();
    
$result = array();
    try {
        
$result $obj->getPdo()->query("CALL getBook()");
        return 
$result;
    } catch (
PDOException $e) {
        print 
"Error!: " $e->getMessage() . "
"
;
        die();
    }
}

function 
insert($title$author$editor$price$isbn$note) {
    if (
$title == NULL) {
        echo 
'Insert a title';
    } elseif (
$author == NULL) {
        echo 
'Insert an author';
    } elseif (
$editor == NULL) {
        echo 
'Insert an editor';
    } else {
        try {
            
//$obj = new Config();
            
$prepare $obj->getPdo()->prepare("INSERT INTO book (title, author_id, editor_id, price, isbn, note) VALUES (?,?,?,?,?,?)");
            
$prepare->execute(array(
                
trim($title),
                
trim($author),
                
trim($editor),
                
trim($price),
                
trim($isbn),
                
trim($note)
            ));
            
header('location:index.php');
        } catch (
PDOException $e) {
            print 
"Error!: " $e->getMessage() . "
"
;
            die();
        }
    }

ho provato così, ma $obj nn è cmq visibile alle funzioni.
come posso fare per condividere una variabile??