Welcome to WebmasterWorld Guest from 54.167.175.107

Forum Moderators: coopster & jatar k

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

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

10+ Year Member



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.
6:34 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



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)

10+ Year Member



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)

10+ Year Member



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)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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 ;)

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

10+ Year Member



Thanks a lot, Patrickrock and Coopster!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month