Operators

An operator is a symbol that tells PHP to perform a mathematical or logical operation. Some operators expect two arguments, some only one. Most operators fall into three categories: arithmetic, logical, and bitwise. There are some exceptions, however. Table 2.4 lists the arithmetic operators.

Table 2.4. Arithmetic Operators
OperatorOperation It Performs
+Addition
-Subtraction and Negation
*Multiplication
/Division
%Modulo Division
++Increment
--Decrement

Addition, subtraction, multiplication, and division are familiar concepts. They may be applied to integers or doubles. Using a string with an arithmetic operator causes the string to be converted to a number first. Modulo division returns the integer remainder of a division. The - operator ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.