Answer the question
In order to leave comments, you need to log in
What is faster curl in php to get the body?
Do you guys have ready-made solutions that will get the page faster than curl? I understand that a lot depends on the bandwidth of the channel of both the local machine and the server from which I receive the body. But still?
Answer the question
In order to leave comments, you need to log in
if post file_get_contents() is not needed, maybe a little faster
You can try fsockopen , it might be faster, but the difference can be so small that it's much more efficient to increase the bandwidth.
All in all, it's up to you.
Here is the code:
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question