Kae Verens

first PHP4/5 difference I've noticed

by kae verens on Jul.08, 2005, under php

I just spent a half hour narrowing down a bug in an application I’d fut some polishing touches on in PHP5. When it was moved onto the production server earlier, it came up with blank pages. I wasn’t on hand to check it out, so couldn’t help over the phone. I had to wait until I could get to a computer to debug it.

The end problem was in a line similar to the following:

$n=$db->query('select id from some_table')->numRows();

The above worked in every server I had available – except the one it was supposed to go on.

To get that code working in PHP4, you must break the object results down:

$n=$db->query('select id from some_table');
$n=$n->numRows();

It’s an annoyance – but at least it’s not a large thing to fix, and the lines that need changing can easily be found by grepping for numRows().


3 Comments for this entry

  • hostyle

    Interesting. Is lack of backwards compatibility going to be one of PHP5′s features?

  • kae

    It’s the other way around, hostyle – I was writing code for PHP5, but the code didn’t work in PHP4. No biggie – it’s a small difference, but I was suprised by it anyway, as I had not come across any other differences up until then.

  • hostyle

    ah yes, speed reading does let me down now and then :)

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...