Fatal: Call to a member function read() on boolean 'xcopy'
<p>I use this code to copy folder to another folder. but after i run i get this error.</p>

<p>Fatal: Call to a member function read() on boolean</p>

<p>code :</p>

<pre><code>function xcopy($source, $dest, $permissions = 0755)
{
// Check for symlinks
if (is_link($source)) {
    return symlink(readlink($source), $dest);
}
// Simple copy for a file
if (is_file($source)) {
    return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
    mkdir($dest, $permissions);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir-&gt;read()) {
    // Skip pointers
    if ($entry == '.' || $entry == '..') {
        continue;
    }
    // Deep copy directories
    xcopy("$source/$entry", "$dest/$entry", $permissions);
}
// Clean up
$dir-&gt;close();
return true;
}
</code></pre>

<p>can anyone tell me how to fix this?</p>

<p>Thankyou</p>