Operators and Expressions

You can now assign data to variables, and you can even investigate and change the data type of a variable. A programming language isn’t very useful, though, unless you can manipulate the data you can store. Operators are symbols that enable you to use one or more values to produce a new value. A value that is operated on by an operator is referred to as an operand.

An operator is a symbol or series of symbols that, when used in conjunction with values, performs an action and usually produces a new value.

An operand is a value used in conjunction with an operator. There are usually two operands to one operator.

Let’s combine two operands with an operator to produce a new value:

4 + 5

4 and 5 are operands and are operated ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition 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.