Problems with PHP Curl receiving data

Source: Internet
Author: User
The receiving end is Print_r ($_post);

The sending side writes a curl to submit the post.

$ch = Curl_init (); Curl_setopt_array ($ch, array (curlopt_url = ' http://myurl/abc.php ', Curlopt_returntransfer = True,curlopt_post = True,curlopt_postfields = ' name=abc&id=123 '); $content = curl_exec ($ch);p Rint_r ($ content); Echo '
=========
'; Echo $content [' name '];

Print out the results:

Array (    [name] = + ABC    [id] = 123) =========a

Why $content[' name ' gets a letter a ...

Reply content:

The receiving end is Print_r ($_post);

The sending side writes a curl to submit the post.

$ch = Curl_init (); Curl_setopt_array ($ch, array (curlopt_url = ' http://myurl/abc.php ', Curlopt_returntransfer = True,curlopt_post = True,curlopt_postfields = ' name=abc&id=123 '); $content = curl_exec ($ch);p Rint_r ($ content); Echo '
=========
'; Echo $content [' name '];

Print out the results:

Array (    [name] = + ABC    [id] = 123) =========a

Why $content[' name ' gets a letter a ...

$content = curl_exec ($ch);

This line of code gets the $content is a string. So you print this string when you echo.
Change the Print_r to Var_dump.

Var_dump ($content);

Get results:

String "Array (    [name] + ABC    [id] = 123)"

echo $content [' name ']; This sentence

$content is a string where ' name ' is being multiplied by the integer 0, so it is the first letter A.

  • 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.