PHP Curl gets no return value

Source: Internet
Author: User
Tags setcookie blank page
Server-side functions
function order_kb () {
$expressodd [0][' odd ']= ' 560860393435 ';
$expressoddjson = Json_encode ($expressodd);
return $expressoddjson;
}

Client request PHP File
$post _data = Array ();
$url = ' http://www.test.com/index.php?m=user&a=order_kb ';
$o = "";
foreach ($post _data as $k = $v)
{
$o. = "$k =". UrlEncode ($v). " & ";
}
$data =substr ($o, 0,-1);
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_postfields, $data);
$result = curl_exec ($ch);
Curl_close ($curl);
Print_r (Json_decode ($result, TRUE));
Print_r (Json_decode ($result, TRUE) [0][' odd ']);//print out to see the results
?>
Why can't I get the return value? Print out a blank page


Reply to discussion (solution)

This website will execute the following JS code on the first visit

function Setcookie (c_name, value, expiredays) {            Document.cookie = c_name + "=" + Escape (value) + ((expiredays==null)?) "": "; expires=" + expiredays) + ";p ath=/";} function Gethosturi () {            var loc = document.location;                    return loc.tostring ();} var exdate=new Date (); Exdate.setdate (Exdate.getdate () +1); Setcookie (' Doaauthreferrer ', Document.referrer, Exdate.toutcstring ()); Setcookie (' Doadfgsjnrsfgsg329gafga3ggs9434sgsgs43tsgshsg35 ', ' # e25d0c3c68dea6df48ffe0664f9d86d24c31ff1d#flbn#1467097484#1739593330# ', ' Tue, June 07:04:44 GMT '); try {      Location.reload (True);  } catch (ERR1) {      try {          location.reload ();      } catch (ERR2) {      location.href = Gethosturi ();      }  }
If you can't simulate execution, then it's definitely not getting the real data.

This website will execute the following JS code on the first visit

function Setcookie (c_name, value, expiredays) {            Document.cookie = c_name + "=" + Escape (value) + ((expiredays==null)?) "": "; expires=" + expiredays) + ";p ath=/";} function Gethosturi () {            var loc = document.location;                    return loc.tostring ();} var exdate=new Date (); Exdate.setdate (Exdate.getdate () +1); Setcookie (' Doaauthreferrer ', Document.referrer, Exdate.toutcstring ()); Setcookie (' Doadfgsjnrsfgsg329gafga3ggs9434sgsgs43tsgshsg35 ', ' # e25d0c3c68dea6df48ffe0664f9d86d24c31ff1d#flbn#1467097484#1739593330# ', ' Tue, June 07:04:44 GMT '); try {      Location.reload (True);  } catch (ERR1) {      try {          location.reload ();      } catch (ERR2) {      location.href = Gethosturi ();      }  }
If you can't simulate execution, then it's definitely not getting the real data.

I wrote that web address casually.

Then you're too bored.

Then you're too bored.

The actual request is "http://www.danhaoxia.com/index.php?m=user&a=order_kb"; Look at this.

$url = ' http://www.danhaoxia.com/index.php?m=user&a=order_kb '; Echo file_get_contents ($url);
Have

BOM head not to say, there is no JSON shadow

$url = ' http://www.danhaoxia.com/index.php?m=user&a=order_kb '; Echo file_get_contents ($url);
Have

BOM head not to say, there is no JSON shadow

Just learned PHP, server-side return value above to do processing?

$url = ' http://www.danhaoxia.com/index.php?m=user&a=order_kb '; Echo file_get_contents ($url);
Have

BOM head not to say, there is no JSON shadow

That should be the test that I just added to the server, and now I've removed the

$url = ' http://www.danhaoxia.com/index.php?m=user&a=order_kb '; Echo file_get_contents ($url);
Have

BOM head not to say, there is no JSON shadow


Server-side functions
function order_kb () {    $expressodd [0][' odd ']= ' 560860393435 ';    $expressoddjson = Json_encode ($expressodd);    return $expressoddjson;}

Go is removed, but only the BOM head is left
How do you call the ORDER_KB function?

Go is removed, but only the BOM head is left
How do you call the ORDER_KB function?


Client request PHP File
 
  $v) {    $o. = "$k =". UrlEncode ($v). " & ";} $data =substr ($o, 0,-1); $ch = Curl_init (); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_returntransfer, 1 ); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_postfields, $data ), $result = Curl_exec ($ch), Curl_close ($curl);p Rint_r (Json_decode ($result, True));p Rint_r (Json_decode ($result, True ) [0][' odd ']);//print out to see the results?>

Go is removed, but only the BOM head is left
How do you call the ORDER_KB function?


Client request PHP File
 
  $v) {    $o. = "$k =". UrlEncode ($v). " & ";} $data =substr ($o, 0,-1); $ch = Curl_init (); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_returntransfer, 1 ); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_postfields, $data ), $result = Curl_exec ($ch), Curl_close ($curl);p Rint_r (Json_decode ($result, True));p Rint_r (Json_decode ($result, True ) [0][' odd ']);//print out to see the results?>

ORDER_KB is not a function of the server? How do you call it?

ORDER_KB is not a function of the server? How do you call it?


With the thinkphp framework, http://www.danhaoxia.com/index.php?m=user&a=order_kb this URL can be called to the function

But he did not return the data, you did not open Ajax mode it?

But he did not return the data, you did not open Ajax mode it?

No, just don't know why the value of return will not be taken

You did not turn on Ajax mode, how does the return value of order_kb output?
Don't you even read the manual?

You did not turn on Ajax mode, how does the return value of order_kb output?
Don't you even read the manual?

How to drive? Just learn, don't understand
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.