Start a conversation

PHP code to set expiration for the index page

PHP language is an open source web scripting language which is included within HTML tags to implement any logic. And Due to popularity of PHP language many web hosting providers have started deploying PHP hosting servers which are actually called cPanel hosting servers to host a PHP website with MySQL to support database of a website. But because of some reason if you want to make any changes in your site so you can set the expiration to your site  means after some date or year your site shows custom error on the page then you can add following code in index page below the “<?php” code and set the date as per your request.

$exp_date = “2012-04-31”;
$todays_date = date(“Y-m-d”);
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
if ($expiration_date <= $today)
{
echo ‘<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html>
<head>
<title>Expired…</title>
</head>
<body>
<h1>What you search</h1>
<p>Now Site is Expired </p>
<hr>
<address>I have set the expiration to my site ,we need to increase expiration date in index page</address>
</body>
</html>
exit;
}

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Diya Ahmed

  2. Posted

Comments