Accessing Other Web Sites with PHP

Even though PHP itself is normally used to create Web sites, it can also access and interact with Web pages on its own. This can be useful for retrieving information, writing spiders (applications that scour the Internet for particular data), and more. Surprisingly, you can access other Web sites in much the same way you would access a text file on your hard drive: by using fopen().

fopen ("http://www.dmcinsights.com/phpadv/", "r"); 

The fopen() function used for opening files can also open Web pages because they are, after all, just files on a server. The parameters for using fopen() are the same (r, w, and a), although you will be limited to opening a file only for reading unless the file's permissions are ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.