title: How to get the FTP error when using PHP
body: <p>I have a script which logs on to a remote server and tries to rename files, using PHP.</p>
  
  <p>The code currently looks something like this example from the php.net website:</p>
  
  <pre><code>if (ftp_rename($conn_id, $old_file, $new_file)) {
   echo "successfully renamed $old_file to $new_file\n";
  } else {
   echo "There was a problem while renaming $old_file to $new_file\n";
  }
  </code></pre>
  
  <p>but ... what was the error? Permissions, no such directory, disk full?</p>
  
  <p>How can I get PHP to return the FTP error? Something like this:</p>
  
  <pre><code>echo "There was a problem while renaming $old_file to $new_file: 
  the server says $error_message\n";
  </code></pre>