Popular Categories

CURL to PHP Converter

This tool convert a command line CURL to PHP CURL. Currently, it knows the following options: -d/–data/–data-binary, -H/–header, -I/–head, -u/–user, compressed, —url and -X/–request.

Example 1 · Example 2 · Example 3 · Example 4 · Example 5

Additional Information:
The cURL stands for ‘Client for URLs’, originally with URL spelled in uppercase to make it obvious that it deals with URLs. It act as a command line tool for getting or sending files using URL syntax. Since curl uses libcurl, it supports a range of common internal protocols, currently including HTTP, HTTPS, FTP, FTPS, GOPHER, TELNET, DICT, and FILE.

Some basic cURL functions:

  • The curl_init() function will initialize a new session and return a cURL handle.
  • curl_exec($ch) function should be called after initialize a cURL session and all the options for the session are set. Its purpose is simply to execute the predefined CURL session (given by ch).
  • curl_setopt($ch, option, value) set an option for a cURL session identified by the ch parameter. Option specifies which option is to set, and value specifies the value for the given option.
  • curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) return page contents. If set 0 then no output will be returned.
  • curl_setopt($ch, CURLOPT_URL, $url) pass URL as a parameter. This is your target server website address. This is the URL you want to get from the internet.
  • curl_exec($ch) grab URL and pass it to the variable for showing output.
  • curl_close($ch) close curl resource, and free up system resources.

It is always recommended that you bookmark such tools as they are very handy while coding as you don’t need to search through again.