Omnimaga
General Discussion => Technology and Development => Web Programming and Design => Topic started by: Sorunome on March 31, 2012, 05:07:15 am
-
Hey, I wanted to know if, and if how, it is possible to opendir() of an external page, e.g. http://www.google.com
-
No, it is not.
-
You could use file_get_contents() to get the html of google, but you couldn't use opendir on it. Opendir only works on a locally-mounted filesystem.
-
Nope. In fact, your PHP script can't tell at all if something on another server is a directory at all, any more than you (as a user) can (for example, is http://example.com/page1 a directory or a file?).
All you can know is the content that server returns to you. In some places, a site might return a plain-text listing of the directory's contents (such as http://eeems.omnimaga.org/files/), while in other places it might return 403 Forbidden, in order not to show you what's inside. And if there's a file called index.html or default.html or anything like that, of course, that's exactly what the server will show you when you try to open that directory.
-
Ah, ok, thanks for your help, it seems all-logical :)