Category Archives

2 Articles

PHP

PHP: Curl vs file_get_contents benchmark

Posted by Kevin Kivi on

I benchmarked curl vs file_get_contents in getting getting headers only and returning the HTTP Status Code.

Here are the results:

kevinkivi@server:~/my/secret/directory$ php curlvsfgctest.php
Testing curl speed

Domain: http://google.com
Status: 301
Domain: http://yahoo.com
Status: 301
Domain: http://nytimes.com
Status: 301
Domain: http://theguardian.com
Status: 301
Domain: http://wikipedia.org
Status: 301

Curl speed was 0.35739207267761


Testing file_get_contents speed

Domain: http://google.com
Status: HTTP/1.0 301 Moved Permanently
Domain: http://yahoo.com
Status: HTTP/1.0 301 Moved Permanently
Domain: http://nytimes.com
Status: HTTP/1.1 301 Moved Permanently
Domain: http://theguardian.com
Status: HTTP/1.1 301
Domain: http://wikipedia.org
Status: HTTP/1.1 301 TLS Redirect

file_get_contents was 1.7153549194336

Below is the source code:

Closing statement: Curl is almost 5 times faster. Use Curl unless you cant.

Code/PHP

PHP: Namecheap.com API Class

Posted by Kevin Kivi on

I built a simple to use class in PHP for the namecheap.com API. It supports all of Namecheap’s API methods. I released the code on GitHub.

Example of usage:

<?php
require 'namecheap.class.php';
$username = 'YOUR USERNAME';
$apiKey = 'YOUR API KEY';
$clientIp = 'IP WHERE THIS YOUR SCRIPT IS HOSTED';
$namecheap = new Namecheap ($username, $apiKey, $clientIp) ;
$data["Command"] = "namecheap.ssl.getList";
$returned = $namecheap->request($data);
print_r($returned)
 ?>

GitHub release: https://github.com/nake89/namecheap