The ternary operator can be confusing, as it dehydrates the longer if/else code blocks into a single line of code. It eliminates the repeating pattern. But what about the ?: syntax? How does that work? When should you use it? Check out the other syntax here. This tip is valid for JavaScript and PHP.
Code Tip: Purposeful Naming
Let’s talk about naming of variables, functions, etc. in your code. In this video, you will learn some handy guidelines on naming by intent to let your code express what it’s doing, why it exists, how to use it, and what to expect from it. This tip is valid for all programming regardless of the language or technology.
PHP Tip: What makes a conditional expression false (falsey state)?
In this video, you will learn the intent of this `if` conditional expression as well as what evaluates to false. This is known as checking the falsey state.
PHP Tip: Use array_merge and Not foreach to Merge Defaults
In this quick tip, Tonya shows you how to reduce your code when you want to merge default parameters (settings) together with the implement. She shows you a shortcode example from WordPress which uses a foreach() to accomplish what one line of code and do, i.e. using array_merge.
Code Tip: Understanding the Ternary Operator
Let’s talk about the ternary operator. It can be confusing for many. In this video, Tonya puts the if/else side-by-side with its equivalent ternary to help you know and understand it. The alternate syntax tip is found here. This tip is valid for JavaScript and PHP.