开发者

curl_exec is directly outputing data?

开发者 https://www.devze.com 2023-03-20 20:40 出处:网络
I have this code 开发者_如何学编程<?php function get(){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, \"http://stackoverflow.com/\");

I have this code

开发者_如何学编程<?php
function get(){
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, "http://stackoverflow.com/");
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $c = curl_exec($ch);
        curl_close($ch);
        die("A");
        return $c;
}

$first = get();


?>

but look what's output! It just prints off everything returned from curl_exec();

how is that possible?


Yes (as you already have tested).

curl_exec PHP Manual does return output directly to the browser unless you make use of the CURLOPT_RETURNTRANSFER constant as documented.

0

精彩评论

暂无评论...
验证码 换一张
取 消