PHP is_numeric() vs is_int()

Some lessons you don’t forget, but this one I did because it doesn’t come up very often.

Don’t use is_int() because, as Jeremy says, it’ll lie to you. Use is_numeric() instead.

Copy the following chunk of code into a php file and run it. You’ll be surprised at the outcome:

$t = "12345";
if( is_int($t ) ) {
    echo $t . " is an int!";
} else {
    echo $t . " is not an int!";
}

The problem is that is_int() thinks a string of numbers is a string, not an integer. The is_int() man page has an example illustrating that but it’s easy to miss. That function should carry a public health warning!

There’s also the ctype_digit() function too but it has it’s own gotcha:

Note: This function require a string to be useful, so for example passing in an integer will always return FALSE. However, also note that HTML Forms will result in numeric strings and not integers. See also the types section of the manual.

Kylie Minogue does Monkey Man

Well, this was a nice start to the day. Yesterday morning I heard a catchy tune coming from the living room so I popped my head in to see Kylie singing with “The Wiggles” on NickJr. They covered Monkey Man by The Specials and I have to take my hat off to Miss Minogue. Wow.

The song is full of energy, it’s happy, it’s got that “get up and go” feel. My foot was tapping as I listened. Who knew Kylie Minogue could do Ska? Dare I say it, but she does a better job of it than The Specials?

The naked Brian Cowen

Earlier this month someone walked into the National Gallery in Dublin, Ireland and hung a nude painting of our illustrious leader, Brian Cowen, in the “National Portrait Collection” section of the gallery.
Another painting was hung in a nearby gallery. More details can be found on this Tribune article.

Brian Cowen

Brian Cowen

All a bit of fun right? Sure, nobody wants to see a satirical nude photo of themselves hung up in public but the pictures were only on display for a short time. One or two newspapers reported on it and the national broadcaster, RTE, carried the following report on Monday night:

I never saw the original news clip. I was barely aware it had happened until this morning when the blogs and twitter were all alight with talk of the apology RTE broadcast last night. They also removed the news clip and article from their site.

RTE has to apologise and be censored for reporting the news? What sort of country are we living in? If Fianna Fail had let things lie all this would have blown over and be forgotten by now.

Ray D’Arcy speaking on TodayFM (a private national radio station) revealed the painter is Conor Casbey yesterday, but he wasn’t the one who hung the paintings. After the show yesterday a Garda called to the TodayFM offices looking for the email of the artist to caution him. The request was refused. Ray admitted that if the Garda hadn’t called he wouldn’t be talking about the paintings today.

More coverage by Irish bloggers:

Grandad has a different viewpoint. Brave of you 🙂

Control of the media is essential at this time, lest they say something negative about His Holiness. In fact, the Director General of RTE should immediately be reassigned to a menial task in the Ringsend Sewage Station as a lesson to the rest of those who would speak ill of our Great Government.

We must all revere and adore His Godliness for his inspired leadership in this time of crisis. Nothing negative must pass our lips.

The North Koreans have the right idea.
cowanposter

(Great caricature by Alan Cavanagh)

So, next time you see something funny about Gordon Brown or Barack Obama be glad you don’t live in Ireland. Spread the news. Check out #picturegate on Twitter.

PS. Many many more blogs are covering picturegate now but take a look at this thread on Creative Ireland. Great photoshopping going on there! (Alastair)

cowen-1

Crash Different

An oldie, but as they say, “a goody”. For all the Mac fans who are sick and tired of their computers crashing. (Hey Mark!)
Found this on a CD while sorting through my CDRs and music collection. Most are now ripped to MP3 and the physical media is heading into the attic for safe storage.

Why is it that most of my compilation CDs are from about 10 years ago? Does music become less relevant the older you get? I’ve never bought music online but if I do, Blue Lights on the Runway by Bell X1 will probably be the first album I buy. Love “The Great Defector”, their current single.

The Simpsons come to Ireland

St. Patrick's Day So, a new Irish themed Simpsons will air tomorrow night to celebrate St Patrick’s Day and the whole world is going gaga over it.

We had lunch in Blarney today and heard from more than one person that the Simpsons will be making an appearance tomorrow at Blarney Castle! I think people are confusing reality with a cartoon storyline. Things are getting out of hand. Next thing you know, Bugs Bunny and Daffy Ducks will be spotted walking out of the Woollen Mills and drinking pints with the locals.

I have the episode set to record on Sky+ anyway. Should be a laugh.

Oh, and it’s not “Patty’s Day”. A pat is something a cow leaves behind in a field and contributes to global warming and is quite smelly. Dung beetles like it too. If you must shorten “St. Patrick’s Day”, it’s “Paddy’s Day”! Thanks Gavin for alerting me to this atrocious misspelling.

WP Super Cache 0.9.1

WP Super Cache version 0.9.1 is now available. WP Super Cache is a page caching plugin for WordPress that will significantly speed up your website.

Major changes under the hood in this release, and many bugfixes:

  • If your blog is installed in a folder then compare the mod_rewrite rules in your .htaccess with those on the admin page. I fixed a bug in how those are generated.
  • Out goes the shutdown function the plugin relied on for years (going back to the days of wp-cache), and in comes plain old output buffering on it’s own.
  • If you’ve had problems clearing the cache on your blog it could be because wp-cron isn’t firing. I’ve added checks for that. Joost helped me debug that and he blogged about it too. You’ll get a nice warning message if those checks fail.
  • If after all that, your cache still doesn’t clear, add $wp_cache_shutdown_gc = 1; to wp-content/wp-cache-config.php to clear the cache at the end of pageload instead of by wp-cron. It will slow down page generation for a tiny number of your users though.
  • The Last and Next garbage collection times are now in the timezone selected for your blog.
  • Added an admin notice on the plugin page to warn that caching has to be enabled. A warning is shown below the plugin activation row too.
  • If your site runs on a Windows server, I fixed a small problem with slashes and creating the config file.
  • The plugin created empty supercache folders, but that’s fixed now.
  • Bad Behaviour support seems to work nicely now!
  • You can now relocate the supercache plugins folder. See $wp_cache_plugins_dir in wp-cache-config-sample.php.
  • I added 2 new filters: wp_cache_served_cache_file in wp-cache-phase1.php (BB uses this) and wp_cache_file_contents in wp-cache-phase2.php where you can filter the contents of the newly created cache before it’s written out to a file.
  • The readme.txt has been updated too warning about using NFS to store the cache folder, solving wp-cron problems, added the list of Apache modules required for expired pages to really expire in the browser cache.

I also added a donation link in the readme.txt and on the admin page. You can hide it with the click of a button but if you’re feeling generous, I’d appreciate a donation.
I don’t expect many donations, that’s how these things work, but if you tell me your site does 100,000 page views a day and you couldn’t live without caching I might be slightly annoyed if you come looking for free support.

PS. Looks like Bad Behavior support is broken because the docs on the BB site were a little misleading and I don’t use the plugin. Grab badbehaviour.php and copy into plugins/wp-super-cache/plugins/ overwriting the file of the same name in that folder.

The Irish Blog Awards in Pictures

As I may have mentioned once or twice before, we were at The Irish Blog Awards on Saturday night. Here are a few photos. They’re after the jump because there are 70 there and I’d hate to see them load every time someone loaded the front page of my site!

Gallery of shots from the photowalk to come tomorrow. Possibly over 100 shots in that. I do like to take photos don’t I?

grandad

BTW – Please Photoshop Grandad above. What’s he saying? Two example to follow ..
Continue reading “The Irish Blog Awards in Pictures”

WordPress and Blacknight power the best Irish blogs

grandad

Last Saturday night many of the Irish blogging community got together in The Cork International Airport Hotel for the Irish Blog Awards. I was there with my wife Jacinta, it was a great night and I was delighted to see so many WordPress powered blogs. Both WordPress.org and WordPress.com blogs were represented again and again among the top bloggers in Ireland.

I had planned on writing a post analysing the breakdown of WordPress vs Blogspot vs MT vs everyone else but lucky for me, Cathal Garvey already did the hard work!

pub

He has some very interesting stats on version numbers, and I’m shocked that “Best Technology Blog” (sponsored by Bitbuzz) has the worst record for upgrading WordPress. Hopefully this attention will encourage those bloggers to upgrade.

WordPress is the most popular blogging software among the Blog Awards nominees and Blacknight is by far the most popular hosting service. I don’t think you can get a better recommendation than that for either WordPress or Blacknight.

BTW – That’s Grandad in the photo above. Go read his blog, Head Rambles. You’ll love it!
PS. Here are the results of the Awards, read more by Red Mum, Robert, Niall and Jason who reminds us we should vote for the excellent Cork International Airport Hotel. TheChrisD has a massive post listing everyone in his feedreader who posted about the Awards, a few pics, and some of the videos shown on the night.
I’ll be uploading photos from the night in a post here and to Pixie later.

PPS. Alan Burke got in touch and asked me to give Drupalcamp Galway a plug. He added, “Maybe we could convert a few WordPress users ;-)” but of course that’ll never happen!

On Saturday 4th and Sunday 5th of April 2009 in Galway, 2 groups of Drupal developers will work on building 2 real working Drupal sites for 2 good causes. They will have 24 hours to complete their website. We are calling organizations, charities and NGOs from Ireland to submit their site proposal. Any organisation can register as long as they are not-for-profit and do not have a Drupal site already running. (A few static HTML pages is the limit for being accepted).

Sounds like a great idea and a worthy one too.

Back from The Irish Blog Awards 2009

Jacinta and I are just back from the The 2009 Irish Blog Awards and we’re elated after the experience. If I thought I could convey half the good humour and energy and enthusiasm I’d try but I know I’d fail dismally. It was a wonderful night, full of great people and I’m only sorry we couldn’t stay longer and chat some more!

winner

Thank you Damien and everyone who helped. You pulled off a hugely success celebration of Irish blogging.

The survivors guide to unemployment

jobless I like this. David Jones was recently laid off from his day job and decided to write a book about his experiences in the hope that it might help others in the same position. The book is called “Oh No: I’ve Lost My Job What Am I Going To Do?” and was written in just a few days.

Last week he was on Newstalk talking about his book when he was contacted by Maryrose Lyons from Brightspark Consulting who suggested that a website would really help his book. I’ll let Gordon continue, he’s one of the team who built the site:

Maryrose gathered a team together consisting of Rachel Earley (Website Graphic designer) , David McDonald (Book Graphic Designer), David Duignan (Photographer), Alex Gibson (Award winning Podcaster ) and myself to put the site together and make the functional stuff like Paypal work.

And so was born Joblessandproud.com. Today, for one day only, you can download David’s book for free. It’s only €4.99 anyway, a steal at that price.

It also has a blog, I’m glad to see powered by WordPress. I’m going to subscribe and see what David makes of this opportunity. It’s wonderful to see that WordPress is part of this venture.