O'Reilly logo

PHP 5 Power Programming by Derick Rethans, Stig Sæther Bakken, Andi Gutmans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.6. Operators

PHP contains three types of operators: unary operators, binary operators, and one ternary operator.

Binary operators are used on two operands:

2 + 3
14 * 3.1415
$i – 1

These examples are also simple examples of expressions.

PHP can only perform binary operations on two operands that have the same type. However, if the two operands have different types, PHP automatically converts one of them to the other's type, according to the following rules (unless stated differently, such as in the concatenation operator).

Type of One of the OperandsType of the Other OperandConversion Performed
IntegerFloating pointThe integer operand is converted to a floating point number.
IntegerStringThe string is converted to a number. If the converted ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required