Want to add Coronavirus data to your website? It’s simple with PHP and JSON. There are numerous resources available to pull data from. For this example I will utilize the COVID Tracking Project API. API Data Visit the COVID Tracking Projects API page and find your State from the “States …
PHP Form Select with Date Range
Create a form select with a range of years automatically with PHP. [php] <select> <?php foreach(range(2008, (int)date("Y")) as $year) { echo "\t<option value=’".$year."’>".$year."</option>\n"; } ?> </select> [/php] The above code will output the following: <select> <option value=’2008′>2008</option> <option value=’2009′>2009</option> <option value=’2010′>2010</option> <option value=’2011′>2011</option> <option value=’2012′>2012</option> <option value=’2013′>2013</option> <option value=’2014′>2014</option> <option …
PHP Convert Time from/to 12 Hour or 24 Hour
Simple way to convert time with PHP’s date and strtotime.
Create an Error Page to Handle all HTTP Errors with PHP
From the land of “why the hell didn’t I think of this sooner”… The following is a drop dead simple method to handling all HTTP error (403, 404, 500 etc.) pages with one single PHP file and a few tweaks to your htaccess. .htaccess Code The first step is to …
Business Days To/Fro with PHP
The below example will help you with finding or setting a date to and/or fro using business days only. I needed this for a project I was working on and thought I would share. [php] <?php function dateFromBusinessDays($days, $dateTime=null) { $dateTime = is_null($dateTime) ? time() : $dateTime; $_day = 0; …
Super Simple Page Cache with PHP
Here is a super simple way serve up a cached version of your HTML. [php] <?php // define the path and name of cached file $cachefile = ‘cached-files/’.date(‘M-d-Y’).’.php’; // define how long we want to keep the file in seconds. I set mine to 5 hours. $cachetime = 18000; // …
PHP Snippets – The Name Says it All
I’ve been following a new website via Twitter. PHP Snippets (www.phpsnippets.info) posts frequent useful PHP code samples. PHP Snippets is maintained by Jean-Baptiste Jung, author of Cats Who Code and WPRecipes. PHP Snippets is a great place to find clean code samples to get you started on your project. I …
Dropbox Tips & Tricks – My Top 5
I love Dropbox; it’s simply amazing and über helpful. Appstorm has published several posts with some really useful Dropbox tips. Below are the five tips and ticks I can’t live without. Tips & Tricks If you’re not familiar with Dropbox, let me first start out by saying you’ve been missing …
Happy Birthday PHP
Happy 15th Birthday to the awesome PHP. Back in 1995, Rasmus Lerdorf issued the first public release of PHP. What is PHP? PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Now you know! PHP Website – http://php.net Related …
How to Easily Monitor Your web Server Using PHP
In order to make sure that your website is always available to the public, you have to monitor it. In this tutorial, I’ll show you how you can easily create a monitoring script that will check your website availability and send an email or sms alert to you if it …
PHP hide_email()
A PHP function to protect the E-mail address you publish on your website against bots or spiders that index or harvest E-mail addresses for sending you spam. It uses a substitution cipher with a different key for every page load. via PHP hide_email().