检查与 PHP 中的 ssh2 函数的连接 [英] check connection with ssh2 functions in PHP
本文介绍了检查与 PHP 中的 ssh2 函数的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要检查与函数http://php.net的连接/manual/en/function.ssh2-connect.php
但是如果我像这样进行检查
But if I made a check like this
$connection = ssh2_connect('myserver.com', 22);
if (!$connection){
echo 'no connection';
}else{
echo 'connection ok';
}
我从不进入echo 'no connection';"
I never get into the line " echo 'no connection'; "
你能解释一下为什么吗?以及如何进行这样的检查?
Can you explain me why? And how to make a check like that?
提前致谢!
推荐答案
这取决于您的服务器.尝试连接到一些不存在的,看看会发生什么.
It depends on your server. Try to connect to some non-existing one and see what happens.
如果你只需要检查连接,那么你可以使用类似http://php.net/manual/en/function.fsockopen.php 也
If you need to check only connection, then you can use something like http://php.net/manual/en/function.fsockopen.php also
这篇关于检查与 PHP 中的 ssh2 函数的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文