2011-09-22 171 views
2

如果我做這樣的事情:持續FTP連接

rename('ftp://user:[email protected]/pub/file1.txt','ftp://user:[email protected]/pub/fileA.txt'); 
rename('ftp://user:[email protected]/pub/file2.txt','ftp://user:[email protected]/pub/fileB.txt'); 
rename('ftp://user:[email protected]/pub/file3.txt','ftp://user:[email protected]/pub/fileC.txt'); 
rm('ftp://user:[email protected]/pub/fileA.txt'); 
rm('ftp://user:[email protected]/pub/fileB.txt'); 
rm('ftp://user:[email protected]/pub/fileC.txt'); 

將PHP的保持同一服務器上的不同業務之間的FTP連接?換句話說,我不知道在這種情況下,PHP是否會創建單獨的連接或保持它活着?如果它創建單獨的連接,那麼當我使用文件包裝器傳輸文件時,如何強制它使用它。我知道我可以使用不同的方法,而不是ftp包裝,但我想知道這是如何與文件包裝。

+0

可能沒有。嘗試使用[PHP的FTP擴展](http://php.net/manual/en/book.ftp.php) – Robik

+0

問題是我不想改變整個代碼,尤其是當前的方法允許我輕鬆地在ftp或sftp之間切換(ssh2.sftp://)。改變這個類將需要很多工作。 –

回答

1

剛剛用Wireshark來看,答案肯定是否。用PHP/5.2.19-win32測試。

如Robik建議使用PHP FTP extension如果您想要連接持久性。

+0

感謝您的檢查,但主要問題是如果可以更改該行爲而不需要退出url風格的協議。所以我現在要離開問題了。 –

+0

你可以很容易地[寫你自己的包裝](http://www.php.net/manual/en/function.stream-wrapper-register.php)來做到這一點... – DaveRandom