Summary: Understanding PHP 8 Functional Differences
A quick overview of differences in string handling, numeric comparisons, and gaining better control to prevent potential code breaks during migration.
We'll cover the following
Key takeaways
We learned about differences in string handling between PHP 8 and earlier versions and how to develop workarounds that address differences in string handling. PHP 8 exerts greater control over the data types of string function arguments, as well as introducing consistency in what happens if an argument is missing or null. A big problem with earlier versions of PHP is that several assumptions were silently made on your behalf, resulting in a huge potential for unexpected results.
We also highlighted issues involving comparisons between numeric strings and numeric data. We learned not only about numeric strings, type-juggling, and non-strict comparisons but also how PHP 8 corrects flaws inherent in numeric string handling that were present in earlier versions.
Another topic covered in this chapter demonstrated potential issues having to do with how several operators behave differently in PHP 8. We learned how to spot potential problems and were given best practices to improve the resilience of our code.
Get hands-on with 1400+ tech skills courses.