gpt4 book ai didi

php - curl 下载网页与符号错误

转载 作者:行者123 更新时间:2023-12-04 18:12:12 25 4
gpt4 key购买 nike

我正在尝试下载网页,例如:

http://www.site.com/savings/thispage?OneId=88&SecondId=185

CURL 在此页面上失败;我怀疑是因为与号。如何转义这个 & 以允许下载完成?

错误是 Unable to resolve host

最佳答案

看看: url_encode(); rawurlencode(); .

Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. This differs from the » RFC 3986 encoding (see rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs.



更新 : 因为错误是 Unable to resolve host ,请确保您的 /etc/resolv.conf文件的权限为 0644 .这将确保安全并允许 Apache/PHP 读取和解析主机名。

您可以通过调用 gethostbyname(); 来检查 PHP 和 Apache 是否可以访问 DNS 服务。

关于php - curl 下载网页与符号错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12393242/

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