Mehdi Rahimi Mehdi Rahimi - 1 year ago 87
PHP Question

loadHTML & loadHTMLFile, which one is faster?

Between these two, which one is faster? Getting content directly by

or first by
and then pass to

$doc = new DOMDocument();


$doc = new DOMDocument();
$ch = curl_init();
$timeout = 500;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);

Answer Source

Add as the last line of your script and try each method at least 3 times to get an accurate idea of which is fastest.

Page generated in 
<?php echo  round((microtime(TRUE)-$_SERVER['REQUEST_TIME_FLOAT']), 4); ?>
 seconds on <?php echo date("M jS Y"); ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download