PHP Curl on port 81

I locally installed 2 Apache Server on port 80 and port 81 using XAMPP. Yam was able to successfully access them through my browser. URLs are currently available at

http://27.4.198.225/ncmsl/check.php 

and

 http://27.4.198.225:81/ncmsl/check.php. 

When I try to write a simple cone code for them

 $ch=curl_init(); $url = "http://27.4.198.225/ncmsl/check.php"; curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); curl_close($ch); 

It works fine for the server on port 80, but does not work for the server on port 81, i.e.

 $ch=curl_init(); $url = "http://27.4.198.225:81/ncmsl/check.php"; curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); curl_close($ch); 

What could be the reason? I tried using CURLOPT_PORT, but this also does not work.

These URLs are LIVE URLs. Can anyone check if they can successfully access them using their own CURL code on their own network.

+4
source share
4 answers

try it

 curl_setopt ($ch, CURLOPT_PORT , 81); 

Update code: -

see this url: - php curl problem

 $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_URL, 'http://27.4.198.225:81/ncmsl/check.php'); $store = curl_exec ($ch); echo substr($store, 1); curl_close ($ch); 
+5
source

Take a look at CURLOPT_PORT in the manual for curl_setopt ()

0
source

Use this parameter to specify the port,

 curl_setopt($ch, CURLOPT_PORT, 81); 
0
source

Try the following:

 curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']); 
0
source

Source: https://habr.com/ru/post/1432675/


All Articles