问题
I am using ups service for my project,I have the following code which is working fine in my localhost,
.......
$fp = fopen($url, "r");
while(!feof($fp)){
$result = fgets($fp, 500);
$result = explode("%", $result);
//print_obj($result);
$errcode = substr($result[0], -1);
switch($errcode){
case 3:
$returnval = $result[8];
break;
case 4:
$returnval = $result[8];
break;
case 5:
$returnval = $result[1];
break;
case 6:
$returnval = $result[1];
break;
}
}
fclose($fp);
.....
But fopen
is not working in my server, i checked ini settings allow_url_fopen On
has been enabled already. Is there any other settings i missed. Kindly advice on this.
回答1:
In some servers, access to distant url ( outgoing traffic on port ) are disabled by network managers, for security reasons. I saw this problem many times before. It may be for this reason.
If it's the reason and you know what url ( and server IP ) you have to request, you can ask for adding some iptables rules to allow access to that URL.
来源:https://stackoverflow.com/questions/9029951/allow-url-fopen-not-working-in-server