Php 通过set_include_path动态包含googleapi客户端库类
我想包括“GoogleAPI php客户端”(我在一个子文件夹博客中手动上传到我的主机)的类,以便在我的网站上使用,我正在尝试使用“set_include_path”函数动态地包括它。但是,当应用require_时,我的代码停止在那里,因此我没有包含它们。我展示了为此目的而测试的代码: 或者,您可以在代码中动态设置相同的ini指令。 设置包含路径(get包含路径()路径分隔符'/path/to/google-api-php-client/src'..); 我的代码:Php 通过set_include_path动态包含googleapi客户端库类,php,path,include,set,google-api-client,Php,Path,Include,Set,Google Api Client,我想包括“GoogleAPI php客户端”(我在一个子文件夹博客中手动上传到我的主机)的类,以便在我的网站上使用,我正在尝试使用“set_include_path”函数动态地包括它。但是,当应用require_时,我的代码停止在那里,因此我没有包含它们。我展示了为此目的而测试的代码: 或者,您可以在代码中动态设置相同的ini指令。 设置包含路径(get包含路径()路径分隔符'/path/to/google-api-php-client/src'..); 我的代码: // 1st try wi
// 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 parameter settings PHP.ini中直接尝试了这个方法,但没有成功。如果您的文件位于/home/u140888/domains/segurosq.com/public_html/blog/中,请尝试以下方法: 设置包含路径('/home/u140888/domains/segurosq.com/public_html/blog/google api php client/'.path_SEPARATOR.get_include_path()) require_once('google-api-php-client/autoload.php') $client=新的Google_客户端();
现在我可以走了。问题是,我没有为我的PHP5.2版本使用正确版本的Google Api文件。现在我能够无缝地实例化这些类。谢谢你的帮助,我真的很感激。:-)