如何使用密码字符串中的"§"来执行 http 请求?



我正在尝试使用以下URL进行HTTP请求:

$url = 'http://user:123§456@myexampleurl.php';

我遇到了一个错误"无效的URL",我认为问题是§。我无法更改密码。我如何使用它?

您应该 urlencode您的密码(如果您不保证它仅包含alpha-numeric ascii字符,也许是用户名(

在您的特定情况下,您的密码将是123%A7456,因为§将被%A7替换为urlencode()

$url = 'http://' . urlencode($username) . ':' 
          . urlencode($password) . '@myexampleurl.php';

最新更新