Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过set_include_path动态包含googleapi客户端库类_Php_Path_Include_Set_Google Api Client - Fatal编程技术网

Php 通过set_include_path动态包含googleapi客户端库类

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

我想包括“GoogleAPI php客户端”(我在一个子文件夹博客中手动上传到我的主机)的类,以便在我的网站上使用,我正在尝试使用“set_include_path”函数动态地包括它。但是,当应用require_时,我的代码停止在那里,因此我没有包含它们。我展示了为此目的而测试的代码:

或者,您可以在代码中动态设置相同的ini指令。 设置包含路径(get包含路径()路径分隔符'/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 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文件。现在我能够无缝地实例化这些类。谢谢你的帮助,我真的很感激。:-)