Force charset utf-8

If you can not change the configuration of Apache server, use this code to force decoding of page to utf-8.

AddDefaultCharset utf-8
Avatar of Chris Coyier
Chris Coyier on

Get Image Information

/*
 * @param string $file Filepath
 * @param string $query Needed information (0 = width, 1 = height, 2 = mime-type)
 * @return string Fileinfo
 */

function getImageinfo($file, $query) {
       if (!realpath($file)) {
               $file = $_SERVER["DOCUMENT_ROOT"].$file;
       }
       $image = getimagesize($file);
       
Avatar of Chris Coyier
Chris Coyier on

Get File Last Updated Date

/*
 * @param string $file Filepath
 * @param string $format dateformat
 * @link http://www.php.net/manual/de/function.date.php
 * @link http://www.php.net/manual/de/function.filemtime.php
 * @return string|bool Date or Boolean
 */

function getFiledate($file, $format) {
       if (is_file($file)) {
               $filePath = $file;
               if (!realpath($filePath)) {
                       $filePath = $_SERVER["DOCUMENT_ROOT"].$filePath;
       
Avatar of Chris Coyier
Chris Coyier on

Make Random Number

function getRandomId($min = NULL, $max = NULL) {
       if (is_numeric($min) && is_numeric($max)) {
               return mt_rand($min, $max);
       }
       else {
               return mt_rand();
       }
}
Avatar of Chris Coyier
Chris Coyier on

Get File Size

/*
 * @param string $file Filepath
 * @param int $digits Digits to display
 * @return string|bool Size (KB, MB, GB, TB) or boolean
 */

function getFilesize($file,$digits = 2) {
       if (is_file($file)) {
               $filePath = $file;
               if (!realpath($filePath)) {
                       $filePath = 
Avatar of Chris Coyier
Chris Coyier on

Video Screencasts

#60: AJAX Refreshing RSS Content
Running time: 22:56
In video #55 the end result was the FeedSmusher, which inserted content from external RSS feeds onto a page of our own. In this screencast, we will start there and use AJAX
Avatar of Chris Coyier
Chris Coyier on (Updated on )

#70: Random Pet Peeves

I just randomly go through some little annoyances and gripes I have with everything from OS X to Photoshop to WordPress to CSS. I thought of about 5 more the second I was done, but I’ll spare you!…

Avatar of Chris Coyier
Chris Coyier on (Updated on )