Thursday, September 5, 2013

Check domain availability using cURL php

9/05/2013

Here is a simple function for checking domain availability using cURL in php.


<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/

function domain_checker($domain) { 

$data = 'http://'.$domain; 

// Create a curl handle to a non-existing location 
$ch = curl_init($data); 

// Execute 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_exec($ch); 

// Check if any error occured 
if(curl_errno($ch)) 
{ 
    return 'The domain is available!'; 
} else { 
    return 'The domain is not available'; 
} 

// Close handle 
curl_close($ch); 
} 


?>



// Usage: 

<?php
domain_check("blogger.com");

?> 

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top