-
To use localStorage in Firefox cookies must be allowed
In case a JavaScript generates a security error in Firefox when using localStorage, I found the advice to make sure the about:config property dom.storage.enabled to true.
But this is not enough! localStorage is only available if cookies are allowed for the domain that serves the web page with the script.
I find this strange, cookies are completely different things.
-
Smaller classes make better code
Tip: read In Praise of Small Classes and its follow-up Making Large Classes Small (In 5 Not-So-Easy Steps) about writing better code. Better here means:
- easier to read and understand, so easier to maintain
- less complex classes
- better testable classes
- a better class and package structure
-
PHP tip: omit ?> from PHP only files
Great tip from the Zend programmer’s Reference Guide:
For files that contain only PHP code, the closing tag (”?>”) is never permitted.
.This is useful as it prevents whitespace after the closing
?>from being accidentally added to the output. I always check PHP files for whitespace manually, but this technique solves that problem automatically. Great! -
MySQL STRICT_TRANS_TABLES mode and truncated text values
I just upgraded Apache, PHP and MySQL to their current versions on my development system. After that a unit test of one of my PHP classes failed on inserting a row in a MySQL table. The test inserts text with a greater length than the maximum column length of a
VARCHARcolumn.This test fails because the new server runs with
STRICT_TRANS_TABLESmode. It means that a inserted value must be equal to the stored value or the statement fails. Without the mode setting the inserted value is truncated to the column’s maximum length.