4 Behavior
This chapter covers
- Understanding how code behaves,
- Reducing simple errors from simple mistakes,
- How to anticipate code behavior better.
All programming languages exist to assist us in creating applications. At face value, they all help us accomplish the same things, but each has its unique source code and approach to addressing particular programming challenges. This brings about the notion that we need to appreciate the behavior of a language.
A language’s behavior dictates how it reacts to certain situations. For instance, single and double quotation marks can be used in PHP to print strings but produce different results when interpolation is attempted. In C-based languages, double quotation marks are used exclusively for strings, and single quotation marks are used for single characters. Right there, we see a difference in the behaviors of the languages.
By understanding a language’s nuanced operations methods, we can avoid potential pitfalls when writing our code. Understanding how PHP will react when the code is written a particular way or when certain inputs are processed using certain techniques is very important in helping us to author stable and maintainable applications.