Suppose you want to include/require any file in your scripts, But before doing so you want to confirm that the included or required file doesn’t contain error. Then in that case you can use the below code to do the same.
/* Implementation */
Creative, Informative and Entertaining Stuff for everyone
Post related to PHP
Suppose you want to include/require any file in your scripts, But before doing so you want to confirm that the included or required file doesn’t contain error. Then in that case you can use the below code to do the same.
/* Implementation */
$requestedUrl = “http://www.example.com/abc.php”;
$tags = get_headers($requestedUrl);
if(preg_match(“/Not Found/i”,$tags[0]) || preg_match(“/Service Unavailable/i”,$tags[0]))
{
echo “Requested Url does not exists”;
}
else
{
echo “Requested Url exists”;
}
By using the below code you can export your data from the database to excel file.
When you run the below code, the excel file get generated and get downloaded to the client machine.
How to check if GD support is enabled or not.
<?php
var_dump(gd_info());
?>
If GD support is enabled then you will get an array in that you will get “GD Version”.
If you didn’t get this that means GD support is not there .
To enable GD support you should install
GD library by the below command
“yum install php-gd” (Fedora Linux)
This will install GD support.
Now when you check the output of the above php code it will display the GD version
function getYMDHMSPastFromTwoDate($startTimeStamp,$endTimeStamp)
{
$years = ”;
$Month = ”;
$Days = ”;
$Hrs = ”;
$Mins = ”;
$totalSecs = ”;
$timePastArr = array();
$date1 = $startTimeStamp;
$date2 = $endTimeStamp;
if($date1 > $date2)
{
$dateDiff = intval($date1 – $date2);
}
else
{
$dateDiff = intval($date2 – $date1);
}
$totalYears = $dateDiff/(365*24*60*60);
$years = floor($totalYears);
$timeRemaining = ($dateDiff – ($years*365*24*60*60));
$totalMonth = $timeRemaining/(30*24*60*60);
$Month = floor($totalMonth);
$timeRemaining = $timeRemaining – $Month*30*24*60*60;
$totalDays = $timeRemaining/(24*60*60);
$Days = floor($totalDays);
$timeRemaining = $timeRemaining-$Days*60*60*24;
$totalHrs = $timeRemaining/(60*60);
$Hrs = floor($totalHrs);
$timeRemaining = $timeRemaining-$Hrs*60*60;
$totalMins = $timeRemaining/60;
$Mins = floor($totalMins);
$timeRemaining = $timeRemaining-$Mins*60;
$totalSecs = floor($timeRemaining);
return $timePastArr = array(‘year’=>$years,’month’=>$Month,’days’=>$Days,’hours’=>$Hrs,’minutes’=>$Mins,’seconds’=>$totalSecs);
}