From the course: PHP Tips, Tricks, and Techniques

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Changes to calculations with strings

Changes to calculations with strings

From the course: PHP Tips, Tricks, and Techniques

Changes to calculations with strings

- [David] Hi, I'm David Powers and welcome to this week's edition of PHP Tips, Tricks and Techniques, designed to help you become a smarter, more productive PHP developer. This week I'm responding to a query, that came from a member about my course, PHP: Uploading Files Securely, the code had worked perfectly for several years, but suddenly it generated an error about a non well formed numeric value, so what did that mean? Calculating with numeric strings has always been a rather cool feature of PHP, you can use a string like this, that begins with a number, but has trailing, non-numeric characters in a calculation, PHP strips off the trailing text and type juggling converts it to a number, but since PHP 7.1, using a numeric string, that has trailing non-numeric characters in a calculation generates an error notice, yeah, big deal, you might be thinking, multiplying 76 trombones by two, well, that's a neat party trick, but who in their right mind would ever need to perform a…

Contents