怎么在Curl中指定传出端口?

亲爱的,我正在尝试从Apache Server执行php curl调用,但我需要指定特定端口(出站)的请求,或者至少知道Apache使用的输出端口的范围。因为目标服务器位于一个严格的防火墙后面,它只允许一个IP和一个特定端口通过。希望得到你的帮助。

You could try this. i think this option CURLOPT_LOCALPORT is what you're looking for

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/");
curl_setopt($ch, CURLOPT_PORT, [destinationport]);

curl_setopt($ch, CURLOPT_LOCALPORT, [sourceport]);

$output = curl_exec($ch);
curl_close($ch);      
print($output);