我想在我的網站上使用「google-api-php-client」類(並且我手動上傳到我的子文件夾博客中的主機)試圖用「set_include_path」函數動態地包含它。但是,在應用require_once時,我的代碼停在那裏,所以我沒有包含它們。我展示了我爲此測試的代碼:動態地通過set_include_path包含Google Api客戶端庫類
或者,您可以在代碼中動態地設置相同的ini指令。 set_include_path(get_include_path()path_separator'/ path/to/google-api-php-client/src');
我的代碼:
// 1st try with the full path to the folder classes Google Api:
set_include_path (get_include_path(). path_separator. '/home/u140888/domains/segurosq.com/public_html/blog/google-api-php-client/src'))
// 2nd try with the route from the subfolder Blog to Google Api classes:
set_include_path (get_include_path() path_separator '/ blog/google-api-php-client/src'..);
// 3rd attempt the route from the folder with Google Api classes:
set_include_path (get_include_path() path_separator '/ google-api-php-client/src'..);
// This line require_once my code stops and you can not instantiate the class within Client.php because it has not been added successfully:
require_once 'Google/Client.php';
我在include_path參數設置php.ini中進入我的cPanel主機或沒有成功託管服務提供商嘗試這樣做甚至直接。