How to Check Website Availability with PHP

In this tutorial, we are going to see how to check website availability with PHP. The following PHP script helps you to check if your website is online and available. It uses PHP and cURL. cURL is the easiest option to check the availability of a website. If you want to check the status of your website, make a cURL request to check if the website is available or online.

How to Check Website Availability with PHP
	function checkWebSite($url){
		// Check if the URL provided is valid
		if(!filter_var($url, FILTER_VALIDATE_URL)){
			return false;

		// Initialize cURL
		$ch = curl_init($url);
		// Set options

		// Get the answer
		$response = curl_exec($ch);
		// Close the cURL session

		return $response ? true : false;

	$url = '';

		echo 'The web site is available.';      
	   echo 'The web site is not available'; 


The web site is available.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *