March PHP-Scripts Blog Archives

Date and time page last updated

A PHP one-liner to keep the date/time the page was last updated:

page last updated <?php echo date(“F d Y H:i:s”, getlastmod() ); ?>

Note: uses the server timezone by default. getlastmod() returns a timestamp and if you are on a shared server (virtual hosting) and cannot change the timezone, let’s say the timezone is off by […]

PHP still #4 programming language, Ruby on the move in TIOBE index

The TIOBE Programming Community index tracks the popularity of different programming languages. Over the last year positions #1-6 have not changed with PHP holding at #4 behind Java (#1), C (#2) and C++ (#3).

Heard a lot about Ruby over the last year or so? It moved from #21 to #11. Definitely on the move.

How to use MySQL REPLACE function

Here’s a MySQL query fuction that’s easy to forget about: REPLACE. Let’s say I have a bunch of records in a field with http://www and want to quickly change all to http://. Here’s the syntax to update:

UPDATE tdurl_1 SET URL = REPLACE(URL, ‘http://www.tdurl.com/’,’http://tdurl.com/’);