homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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?
GreenLeaf




msg:1303276
 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()?
Thanks.

 

patrickrock




msg:1303277
 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.

GreenLeaf




msg:1303278
 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()?

patrickrock




msg:1303279
 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.

coopster




msg:1303280
 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."

GreenLeaf,


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.

Resource:
Using remote files [php.net]

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

GreenLeaf




msg:1303281
 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