I have classes included on my bootstrap.php and variables instantiated on the classes included, When I included bootstrap.php it gives me a Call to a member function on a non object
bootstrap.php
require_once "config/constants.php";
require_once "libraries/Dropbox/DropboxClient.php";
$dropbox = new DropboxClient(array(
'app_key' => DROPBOX_CONSUMER_KEY,
'app_secret' => DROPBOX_CONSUMER_SECRET,
'app_full_access' => true,
),'en');
index.php
require_once "bootstrap.php";
dropbox_file_tree();
function dropbox_file_tree()
{
if(!empty($access_token)) {
$dropbox->SetAccessToken($access_token);
}
$files = $dropbox->GetFiles("",true);
print_r($files);
}
It’s nothing to do with
include, it’s a scope issue, functions only see local variables.You have to use the
globalkeyword or the$GLOBALSsuperglobal or pass it as a parameter to the function.