simplexml and str_repeat/number_format

This morning I upgraded from php 5.2.11 to 5.3.4 and I’ve been having some problems with numbers in objects.

Before the upgrade, passing a number in a simplexml element into str_repeat or number_format worked without any problems. Since the change there have been a lot of problems with str_repeat and number_format - when the number comes from a simplexml element they throw an error about the input being an object instead of a double/int. Casting them to float/int solves the problem but I’d really rather it just went back to the way it was rather than having to go through the whole application and change every use of number_format and str_repeat.
I think a lot of things got changed, not just the php version - we needed to install SOAP and the hosting company said we had to use cpanel’s cpEasyApache and I don’t think it had be using that before so its hard to say how much got changed and what is causing this problem.
Possibly related, one of the other sites on the server was using number_format with an empty string as the second parameter - that started throwing and error that wasn’t there before - obviously previously php had been interpreting that empty string as 0 and coping fine with it - so why did it stop?

Sponsor our Newsletter | Privacy Policy | Terms of Service