gpt4 book ai didi

php - file_get_contents 替代函数或方法?

转载 作者:行者123 更新时间:2023-12-03 20:30:31 27 4
gpt4 key购买 nike

在某人的服务器中,出于安全原因,file_get_contents 被禁用。我需要检索 xml 数据。那么,最好的做法是:

  1. 验证服务器是否支持file_get_contents
  2. file_get_contents有替代方法吗?

最佳答案

您可以通过检查 ini 指令 allow_url_fopen 来检查是否可以在 file_get_contents() (以及 fopen() 系列函数)中使用 url。 :

ini_get('allow_url_fopen'); 

您可以使用以下方法绕过这些限制:

  1. cURL
  2. fsockopen()

我强烈推荐cURL。 fsockopen() 更脏。

关于php - file_get_contents 替代函数或方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3515583/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com