I recently came across this genius bit of code on HTTP POST from PHP, without cURL and am wondering if POSTing with cURL or the fopen() provided by PHP.
If one is faster, why? If they are both slow, how can I speed them up?
If I'm invoking the POST page with another POST, instead of loading the page, will it load faster because there is no browser processing?
2 Answers
Not really genius... it's the old fashioned way before cURL. Both methods are valid.
Both methods go via the internet/network so both are at the mercy of latency in general... however cURL should be slightly quicker and the preferred mechanism.
2 Comments
DaveRandom
it's the old fashioned way before cURL. - technically cURL support was first. curl_init(): (PHP 4 >= 4.0.2, PHP 5), stream_context_create(): (PHP 4 >= 4.3.0, PHP 5)Brian
OK... true... in practice many people (including myself in early life) shied away from cURL :)
allow_url_fopenis often disabled in shared environments) and functionality-wise it is vastly superior. They may even both use libcurl anyway, depending on the installation setup:Beginning with PHP 4.3.0 you can configure PHP to use cURL for URL streams --with-curlwrappers