简体   繁体   English

file_get_contents('http://localhost/api/index.php?get = x'); 如何使其工作?

[英]file_get_contents('http://localhost/api/index.php?get=x'); how to make it work?

On my local host i wanna test my API, put every time i use the statement : 在我的本地主机上,我想测试我的API,每次我使用以下语句时:

file_get_contents('http://localhost/api/index.php?get=x');

the script stops with " timeout ", while the URL up there works fine when requested the normal way !. 该脚本以“超时”停止,而正常请求时,该URL可以正常工作!

Hint: i think it have something to do with the php.ini file !? 提示:我认为这与php.ini文件有关!

secondly, using cURL, ( file_get_contents + stream_creat_content ), would be faster ?, i needed it to respond very fast 其次,使用cURL(( file_get_contents + stream_creat_content ),会更快吗?,我需要它快速响应

Thanks in advance :) 提前致谢 :)

This is probably more of a firewall issue than to do with php.ini. 与使用php.ini相比,这可能更多是防火墙问题。

The fastest way to do this, however, will always be a direct include() to a file path. 但是,最快的方法始终是直接将include()指向文件路径。 It would probably require some re-working of the API (because you shouldn't set $_GET variables programmatically), but saves a ton of overhead. 可能需要对API进行一些修改(因为您不应该$_GET编程方式设置$_GET变量),但可以节省大量开销。 If you need this in production, it's most likely worth making the changes. 如果您在生产中需要此功能,则最有必要进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM