Sample code for 30+ languages & platforms
PHP Extension

Transition from SFtp.ReadDir to SFtp.ReadDirListing

Provides instructions for replacing deprecated ReadDir method calls with ReadDirListing.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$sftp = new CkSFtp();

// ...
// ...

$handle = $sftp->openDir('.');
// ...
// ...

// ------------------------------------------------------------------------
// The ReadDir method is deprecated:

// dirObj is a CkSFtpDir
$dirObj = $sftp->ReadDir($handle);
if ($sftp->get_LastMethodSuccess() == false) {
    print $sftp->lastErrorText() . "\n";
    exit;
}

// ...
// ...

// ------------------------------------------------------------------------
// Do the equivalent using ReadDirListing.
// Your application creates a new, empty SFtpDir object which is passed 
// in the last argument and filled upon success.

$dirOut = new CkSFtpDir();
$success = $sftp->ReadDirListing($handle,$dirOut);
if ($success == false) {
    print $sftp->lastErrorText() . "\n";
    exit;
}

// ...
// ...

$sftp->CloseHandle($handle);

?>