Closed
Description
Description
It is not possible to bint to ip4 address using context options any more. In documentation:
bindto
Used to specify the IP address (either IPv4 or IPv6) and/or the port number that PHP will use to access the network. The syntax is ip:port for IPv4 addresses, and [ip]:port for IPv6 addresses. Setting the IP or the port to 0 will let the system choose the IP and/or port.
but in fact it is not allow us to put 0 for ip address.
The following code:
<?php
$url = 'https://google.com';
$ctx = stream_context_create([
'socket' => [
'bindto'=>'0:0'
],
'http' =>
[
'timeout' => 10,
],
]);
$feed = file_get_contents($url, false, $ctx);
Resulted in this output:
file_get_contents(): Invalid IP Address: 0
But I expected this output instead:
actual content of google page
PHP Version
PHP 8.2.5
Operating System
No response