datasync
New Member
- Messages
- 16
- Reaction score
- 0
- Points
- 1
I tried testing to see if curl works using the following code, and it says that it is enabled, however when I check to see if a website exists, it keeps returning true even though the website doesn't exist.
This says that cURL is enabled:
This function keeps returning true when the clearly doesn't exist:
This says that cURL is enabled:
PHP:
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
PHP:
if (isDomainAvailible('http://www.googfenjnkfele.com'))
{
echo "Up and running!";
}
else
{
echo "Woops, nothing found there.";
}
//returns true, if domain is availible, false if not
function isDomainAvailible($domain)
{
//check, if a valid url is provided
if(!filter_var($domain, FILTER_VALIDATE_URL))
{
return false;
}
//initialize curl
$curlInit = curl_init($domain);
curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curlInit,CURLOPT_HEADER,true);
curl_setopt($curlInit,CURLOPT_NOBODY,true);
curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
//get answer
$response = curl_exec($curlInit);
curl_close($curlInit);
if ($response) return true;
return false;
}