Quantcast
Channel: Phil's Blog » php
Browsing latest articles
Browse All 10 View Live

Image may be NSFW.
Clik here to view.

Solved! phpMyAdmin cannot start session without errors

This was a bit of a ridiculous error. It occurred after a PHP upgrade to 5.2.17 running under Apache with mod_php. Initially phpMyAdmin just rejected the login which clearing the browser’s cookies...

View Article


Image may be NSFW.
Clik here to view.

PHP – Converting bytes to a readable format

The following function takes in a number of bytes and the number of decimal places required in the output and returns the result in a readable format: Source code   function readable_filesize($bytes,...

View Article

Image may be NSFW.
Clik here to view.

Horribly amazing PHP – check if you’re on the last iteration of a foreach loop

The code is so horrible, it’s gone a full circle and become amazing once again. It’s a method of finding if you’re on the last iteration of a foreach loop. As with anything that uses array pointers in...

View Article

Image may be NSFW.
Clik here to view.

PHP – Why you should use the Factory Method Pattern and how you should do it

This article assumes you’re using PHP version 5.3 or above. If you are not, you should note that “the PHP 5.2 series is NOT supported anymore” and you should really upgrade. The Factory method...

View Article

Image may be NSFW.
Clik here to view.

PHP – Accurately detecting the type of a file

When files are being uploaded, you cannot rely on the MIME typeWikipedia: An Internet media type[1] is a standard identifier used on the Internet to indicate the type of data that a file contains....

View Article


Image may be NSFW.
Clik here to view.

PHP: Find the last day of the month

In PHP you can pass the t format character to the date() function in order to get the number of days in the month. Since this number also happens to be the date of the last day of the month, you can...

View Article

Image may be NSFW.
Clik here to view.

PHP: Find number of weeks in a given month

The following function finds the number of weeks in a given month, assuming Monday as the first day of the week. Source code   <?phpfunction weeks_in_month($month, $year) { // Start of month $start...

View Article

PHP: Interfacing with HeatMiser WiFi thermostats

I’m quite a big fan of writing code that interfaces with physical data. It somehow feels more fulfilling to see or feel the results. On top of my repertoire of the Foscam FI8908W Recorder and TK110 GPS...

View Article


Image may be NSFW.
Clik here to view.

Raspberry Pi Project – A 1960s wallbox interfaced with Sonos

The inspiration for this project came from @nivnov pointing me to http://wallbox.weebly.com/. I had somewhat of a different take on the circuitry and software than it’s author, Steve Devlin. The pulse...

View Article


Image may be NSFW.
Clik here to view.

How to force TLS v1.0 in PHP

PHP 5.6+ Users This is a new feature as documented on the PHP 5.6 OpenSSL Changes page. At time of writing this, PHP5.6 is in Beta1 and thus this isn’t overly useful. People of the future – lucky you!...

View Article
Browsing latest articles
Browse All 10 View Live