Example of get and post methods using HTTP calls in PHP, getpost_php tutorial

Source: Internet
Author: User

Examples of Get and post methods that use HTTP calls in PHP, Getpost


The functions used are curl_init, curl_setopt, Curl_exec,curl_close.

The default is the Get method, and you can choose whether to use headers:

$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, "$url") curl_setopt ($ch, Curlopt_timeout, 2); curl_setopt ($ch, curlopt _header, 1); If set to 0, headercurl_setopt ($ch, curlopt_returntransfer,1) is not used, $result = curl_exec ($ch); Curl_close ($ch);

Post method:

$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' $ch '); curl_setopt ($ch, curlopt_post,1); curl_setopt (, Curlopt_ returntransfer,true); $vars =sprintf (' from=%d&to=%d&subject=%s&body=%s ', $from, $to, UrlEncode ($subject ), UrlEncode ($body)); curl_setopt ($ch, Curlopt_postfields, $vars); $ret = Curl_exec ($ch); Curl_close ($ch);

PHP $_post differs from $_get and $_request (online articles are exempt)

HTTP requests have post and get. You can specify that the action is post or get when you write the form form. The variable passed by the Post method is saved in the array $_post, $_get the variable passed by the Get method. Both are included in the $_request.
For example



</form>

In t.php, you can use $_get[' AAA ' to get the data that is filled in on the Web form.

When the action in the form is GET, use $_get;action as POST with $_post. Both are available $_request

[PHP] When to receive value get with post

See if you submit the way is get or post, the general form submission has method specified, address bar is used $_get to fetch, such as: www.tbsoo.com/cases.htm?s=&page=4 page in the Get to fetch, If your page has been submitted from the table dropdowns, then use $_request, or write a judgment, get not to use post to take, but still with REQUEST most convenient

http://www.bkjia.com/PHPjc/887347.html www.bkjia.com true http://www.bkjia.com/PHPjc/887347.html techarticle examples of Get and post methods that use HTTP calls in PHP, the functions used by Getpost are Curl_init, curl_setopt, Curl_exec,curl_close. The default is the Get method, you can choose whether to use header: ...

  • Related Article

    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.