Hirdetés
- Samsung Galaxy Watch4 és Watch4 Classic - próbawearzió
- Szívós, szép és kitartó az új OnePlus óra
- Xiaomi 14T Pro - teljes a család?
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Bemutatkozott a Poco X7 és X7 Pro
- Fotók, videók mobillal
- Apple Watch
- Megbüntették, ezért feloszlatná az EU-t Elon Musk
- Vivo X300 - kicsiben jobban megéri
- Minimális változásokat hozhat a Google Pixel 10a
Új hozzászólás Aktív témák
-
Sk8erPeter
nagyúr
válasz
Lacces
#10560
üzenetére
Azért nem működik, mert be kell tenned még ezt:
// This will make cURL follow the redirects (@see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);Tehát a teljes függvény:
/**
* Download a website or any other file using cURL
*
* @see http://www.jonasjohn.de/snippets/php/curl-example.htm
* @see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1
*
* @param string $Url
* @return string
*/
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// This will make cURL follow the redirects (@see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Set a referer
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}Teszt:
$curl_download = curl_download('http://www.example.org/');
echo $curl_download;
Új hozzászólás Aktív témák
- BESZÁMÍTÁS! ASUS H510M i5 11400F 16GB DDR4 512GB SSD RTX 2060 Super 8GB Zalman T4 Plus CM 500W
- Telefon felvásárlás!! Xiaomi Redmi Note 13, Xiaomi Redmi Note 13 Pro, Xiaomi Redmi Note 13 Pro+
- Jo Nesbo: LEOPÁRD (nem olvasott)
- MacBook felvásárlás!! MacBook, MacBook Air, MacBook Pro
- GYÖNYÖRŰ iPhone 13 mini 256GB Blue -1 ÉV GARANCIA - Kártyafüggetlen, MS3904
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: ATW Internet Kft.
Város: Budapest


