curl --resolve equivalent in PHP CURL library curl --resolve equivalent in PHP CURL library curl curl

curl --resolve equivalent in PHP CURL library


First, the best way to get an answer to how any curl option translates to libcurl (or PHP/CURL) is by using the --libcurl option.

If you do, you will learn that --resolve translates to CURLOPT_RESOLVE with libcurl, supported in PHP since 5.5.0. Supported by libcurl since 7.21.3.


I have a solution to this with the help of Python.

In the .php file, just echo the output of python:

<?phpecho passthru("python python.py");?>

In python.py:

import httplibconn = httplib.HTTPSConnection('127.0.0.1');url = "example.com"conn.request("GET", url)content = conn.getresponse()print content.read()conn.close()


if you are going to bother to fork another process, just fork curl itself with the "--resolve" option versus yet another script.