curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl -u username:password http://example.com #To avoid password being visible curl -u username http://example.com