在远程服务器上使用RecursiveDirectoryIterator

时间:2014-08-28 16:58:45

标签: php phpseclib

我有一个适用于独立VPS的脚本(这是一个片段

//Iteration in Directory 
$path = realpath('registry');
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
$path_live = array();


foreach($objects as $name => $object)
{
if (is_file($name))
    $path_live[] = $name;
}


-------------------------------------------------------------------------------

我想让这个在两个VPS之间工作吗?

我已安装phpseclib并可以登录远程VPS,但我不知道如何让它工作。

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

//Iteration in Directory 
$path = realpath('registry');
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
$path_live = array();


foreach($objects as $name => $object)
{
if (is_file($name))
    $path_live[] = $name;
}

//Iteration in Directory 
$path2 = realpath('...');
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path2), RecursiveIteratorIterator::SELF_FIRST);
$path_live = array();


foreach($objects as $name => $object)
{
if (is_file($name))
    $path_live[] = $name;
}

适合我。如果您正在尝试使用两个VPS,那么您将不得不详细说明。