I’m using DirectoryIterator class to list ftp content:
$a = new DirectoryIterator(‘ftp://user:password@host’);
If there is an at “@” character in login, i get an error:
failed to open dir: operation failed
How i can escape @ symbol in login?
I try:
%40,
+
\@
RFC1738 mandates the special characters like
@should be urlencoded in the ftp:// scheme. So using%40in place of the @ in a password fragement would be correct.But you just wanted the
user:password@prefix before the hostname. Those don’t need escaping. And it’s already natively supported by the ftp fopen url wrapper:Above ftp:// url works for me with
DirectoryIteratortoo, but gives some obscure warning and different results. So I would test with the native functions first.