Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
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)
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
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."
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 ;)
GreenLeaf msg:1303281 3:47 pm on Apr 27, 2005 (gmt 0)
Thanks a lot, Patrickrock and Coopster!