Development

memcache: set vs. replace

When using memcache from PHP, you can save values with either set or replace. You can probably safely ignore the replace method: “Memcached::replace() is similar to Memcached::set(), but the operation fails if the key does not exist on the server.” - PHP Documentation

Adding to php arrays

In PHP many things can be done several different ways. Picking which way to do something may be a matter of personal taste or habit. Sometimes however, things may be much clearer for the next developer, if you choose one way over another. A very simple example of this, is adding a new item to an array. Often I come across this construct: $valuepairs[] = 'Some value' It’s valid and compact syntax, but in terms of clarity, I’d prefer this construct anytime:

Mysql: display row count for all tables in a database

When playing the role of the DBA, it’s often useful to get a quick listing of how many rows each table in a database contains. The syntax for this is pretty simple in Mysql: SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '***database name***'; Replace database name with the actual database name in the SQL above. Notice that when using innodb tables, it’s only a rough estimate.

Removing the hash part of an URL

A url may contain a hash/an anchor reference. If you need to remove it from url, it’s quite easy. Here’s a short recipe on how to do it in PHP (including a little test input): $urls = array( 'http://example.com/', 'http://example.com/#test', 'http://example.com/?id=1', 'http://example.com/?id=1#test', 'http://example.com/?id=1&id2=2#test#test', 'http://example.com/?id=1#test#test' ); foreach ($urls as $url) { if (strpos($url, '#')) { $url = substr($url, 0, strpos($url, '#')); } echo $url, "\\n"; } Apart from removing the hash ending from urls, the function can naturally also be used on any number of other similar cases, where you need to trim a string.

Moving to PHP on 64 bit... the isssues & challenges

So your current website - if running PHP - and it seems to work just fine. I am however working on a project, where the new servers are running on a 64 bit version of the OS. This change seem to cause a number of potential issues, and as there didn’t seem to be a resource collection the issues, I’ll try to post a few notes on the experience. Please feel free to add applicable notes and links in the comments.