0
$Link = 'http://somewebsite.com/api.php?message=someMessage&user_id=' . $UserID . '&password=' . $UserPW;
echo $Link;
echo "<br><br>";
$PageResponse = file_get_contents($Link);
隐私我不能发布一个工作示例,但是这是我遇到的问题。PHP file_get_contents在URL中更改apersand
当我回声$链接它返回:
http://somewebsite.com/api.php?message=someMessage&user_id=redacted&password=redacted
不过的file_get_contents回报和错误,看起来像这样:
Warning: file_get_contents(http://somewebsite.com/api.php?message=someMessage&user_id=redacted&password=redacted): failed to open stream: No connection could be made because the target machine actively refused it. in C:\wamp64\www\hello.php on line 14
,如果你会发现,它正在改变“& “字符&
打破了网址。有没有简单的方法来解决这个问题?
这不是一个错误,它是一个功能 – Calimero
您是否在使用'file_get_contents'之前尝试过'html_entity_decode'这个url字符串?否则'str_replace'会有帮助。 – Kapparina
已尝试解码并替换。转换仍然存在 – kamelkid2