I\'ve seen numerous methods of POSTing data with PHP over the years, but I\'m curious what the suggested method is, assuming there is one. Or perhaps there is a somewhat uns
There isn't really a standard way. In code meant for distribution, I generally check cURL, file_get_contents and sockets, using the first one found. Each of those supports GET and POST, and each of those may or may not be available (or work) depending on the PHP version and configuration.
Basically something like:
function do_post($url, $data) {
if (function_exists('curl_init') && ($curl = curl_init($url))) {
return do_curl_post($curl, $data);
} else if (function_exists('file_get_contents') && ini_get('allow_url_fopen') == "1") {
return do_file_get_contents_post($url, $data);
} else {
return do_socket_post($url, $data);
}
}