ftp_connect()不返回资源ID [英] ftp_connect() does not return a resource id

查看:66
本文介绍了ftp_connect()不返回资源ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

突然在服务器上执行此操作

Suddenly when I'm doing this on my server:

<?php 
$connection = ftp_connect("ftpserver"); // connect to server
print($connection);print("test");die();
?>

它不返回资源ID#.

它仅在特定服务器上发生,如果我在另一台服务器上尝试相同的代码,它将返回:

It happens only on a particular server, if I try the same code on another server it will return:

Resource id #2test

这是服务器配置吗?该服务器上最近没有任何更改.它仅打印测试",不打印null或其他内容.我已经尝试了多个ftp服务器,以确保未禁止该服务器IP.

Is it a server configuration? Nothing changed on that server recently. It prints just "test", no null or something else. I've tried multiple ftp servers to make sure that the server IP is not banned.

尝试过 function_exists('ftp_connect')就是这样.

更新:检查/var/log/syslog以查看它是否被防火墙阻止.

Update: check /var/log/syslog to see if it is blocked by firewall.

推荐答案

打印 false 不会产生任何结果( false 转换为空字符串).

Printing false yields nothing (the false converts to an empty string).

使用 var_dump($ connection)进行验证.

您很可能会得到:

bool(false)

这意味着您无法连接到"ftpserver".

Meaning that you cannot connect to the "ftpserver".

ftp_connect 应该发出警告,提示有关连接问题的详细信息.

The ftp_connect should issue a warning with details about the connection problem.

这篇关于ftp_connect()不返回资源ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆