homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Which function do i need to read the page through http?

 5:22 pm on Apr 21, 2005 (gmt 0)

I need read the html page through http and extract the links from it. Which function is better to use for this purpose: fopen() + fread(), file_get_contents(), or fsockopen()?



 6:34 pm on Apr 21, 2005 (gmt 0)

if the fopen wrappers are installed I like to use file_get_contents() since it fetches all the html right into a string ready for me to process.


 2:40 pm on Apr 22, 2005 (gmt 0)

Thanks, Patrickrock,

I'm sorry for silly question, but how could i know are the fopen wrappers installed or not?
Are there any advantages of using fsockopen() over file_get_contents()?


 9:46 pm on Apr 22, 2005 (gmt 0)

try this and see what happens

echo file_get_contents("http://anywebsite.com");

if it spits out the webpage well the wrappers are enabled. =)

They are probably enabled. just test it and see.


 2:26 am on Apr 27, 2005 (gmt 0)

Welcome to WebmasterWorld, patrickrock, and good insight. The PHP developers mention that "file_get_contents() [php.net] is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance."


As long as allow_url_fopen [php.net] is enabled in php.ini, you can use HTTP and FTP URLs with most of the functions that take a filename as a parameter.

Using remote files [php.net]

Should get you going down the right path, anyway ;)


 3:47 pm on Apr 27, 2005 (gmt 0)

Thanks a lot, Patrickrock and Coopster!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved