From the course: PHP for WordPress

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Comparison operators and the truth

Comparison operators and the truth

From the course: PHP for WordPress

Comparison operators and the truth

- [Instructor] Determining if something is true or false is a powerful aspect of a programming language. It's the root of all decision making, and it's how you tell the program exactly what to do and when to do it. So let's take our first step into decision making and programs and look at comparison operators. Comparison operators help us compare values or variables. And we will learn how they work and how to combine those operations to check for complex conditions. First, a comparison operator allows us to compare values and evaluate them as true or false. The most basic comparison operator is the equality operator, which is two equal signs. And it's two equal signs because a single equal sign is reserved for assignments. So if you want to check to see if two values are equal, you would say something like 10, equals, equals, 10. And that of course is true. 10, equals, equals, 20 is false. And since PHP is weak typed, checking for equality only ignores the type of variable. PHP will…

Contents