Home > Article > Backend Development > PHP uses CURL proxy problem
Use a socket5 proxy to access Google. It works in command line mode, but the PHP code does not work. It returns false directly
The code is posted, please help me solve it
The proxy string is written as tcp://127.0.0.1:1080
Try it,
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); if ($this->proxy) { curl_setopt($ch, CURLOPT_PROXY, $this->proxy); }
The above is the configuration when I did Google, it works normally.
The above is the content of socks5 - PHP using CURL proxy problem. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!