我已經包含在我的bootstrap.php和實例化的類包括,當我包括bootstrap.php中它給了我一個電話成員函數的非對象變量類要求一旦超出範圍內的功能
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);
}
您需要將'$ dropbox'實例傳遞給函數即可。每個功能都有自己的本地範圍;默認情況下爲空。 – mario