Which code is faster? Better?

From: Date: Thu, 20 Jun 2002 13:07:59 +0000
Subject: Which code is faster? Better?
Groups: php.general 
Request: Send a blank email to php-general+get-103113@lists.php.net to get a copy of this message
I have a script that retrieves data from web pages. I have two examples I have written and I am wondering which is faster and which is better. I think if it's a page with a lot of data on it, the first example may be better because I am not reading in the entire file...but I am not sure if it's the best way to do it. Thank you in advance for anyone's comments. //Example 1 $US_Market = " http://finance.yahoo.com/mnvl?e=O <http://finance.yahoo.com/mnvl?e=O> "; $USopen = fopen($US_Market, "r"); $US_Results = fread($USopen, 1024); fclose($USopen); if ( empty($US_Results)) { echo 'Had problem opening file.'; } $US_Results = implode('', $US_Results); echo $US_Results; //Example 2 $US_Markets = @file('http://finance.yahoo.com/mnvl?e=O'); if ( empty($US_Markets)) { echo 'Had problem opening file.'; } $US_Results = implode('', $US_Markets); echo $US_Results; Christopher J. Crane Network Operations Manager IKON Office Solutions 860.659.6464

« previous php.general (#103113) next »