500 Using Operators Using Operators The three types of operators used in PHP are mathematical, relational, and logical operators. Mathematical operators calculate numeric results such as adding, multiplying, or dividing numbers, as shown in Table 4-1. Table 4-1 Mathematical Operators Mathematical Operator Purpose Example + Addition 5 + 3.4 - Subtraction 203.9 – 9.12 * Multiplication 39 * 146.7 / Division 45 / 8.41 % Modula division 35 % 9 = 8 (returns the remainder) Relational operators compare two values and return a True or False value. The seven comparison operators available are shown in Table 4-2. Table 4-2 Relational Operators Relational Operator Purpose == Equal === Identical != or Not equal < Less than Greater than >= Greater than or equal to PHP uses three equal signs (===) to compare to values and determine if they are of the same data type. For example, PHP treats 14.0 and 14 as identical because both are numbers, but 14.0 and “14.0” wouldn’t be considered equal because one is a number and the other is a different data type (a string). Logical operators compare two Boolean values (True or False) and return a single True or False value, as shown in Table 4-3.
Using Operators 501 Table 4-3 Logical Operator Logical operators Truth Table && (AND) True && True = True True && False = False False && True = False False && False = False || (OR) True || True = True True || False = True False || True = True False || False = False XOR True XOR True = False True XOR False = True False XOR True = True False XOR False = False ! !True = False !False = True Book V Chapter 4 PHP Increment and decrement operators PHP has a special increment (++) and a decrement (--) operator, which simply adds or subtracts 1 to a variable. Typically, adding 1 to a variable looks like this: j = 5; i = j + 1; The increment operator replaces the + 1 portion with ++, such as j = 5; i = ++j; In the preceding example, the value of i is j + 1 or 6, and the value of j is also 6. If you place the increment operator after the variable, such as j = 5; i = j++; Now the value of i is 5, but the value of j is 6. The decrement operator works the same way except that it subtracts 1 from a variable, such as j = 5; i = --j;
Agreed in 2016, the motive of the General Data Protection Regulation (GDPR) is to better protect the personal data of European Union “data subjects” – EU citizens and other nationals physically present in the EU at the time data are collected. Visit: https://www.hipaajournal.com/gdpr-training/