FAQ |
Kalender |
2016-04-06, 20:39 | #1 | ||
|
|||
Mycket flitig postare
|
de kommer från php.net
min tanke är givetvis att det skall fungera bäst i de fallen där blir något strul, typ att domänen exempel.com filen hämtas ifrån är otillgänglig av olika anledningar. Då vill jag inte att scriptet hänger sig Motivera gärna era svar :-) <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://exempel.com/filename.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> ELLER <?php $url = "http://www.example.org/"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $contents = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); echo "\n<br />"; $contents = ''; } else { curl_close($ch); } if (!is_string($contents) || !strlen($contents)) { echo "Failed to get contents."; $contents = ''; } echo $contents; ?> |
||
Svara med citat |
|
|