Category: Operators in PHP

Operators in PHP

PHP error control operator @

PHP error control operator @

PHP error control operator is @. When this operator is prepended to any PHP expression then any error messages that might be generated by that expression will be ignored. Sample (without @ operator) Output...

Operator Precedence

Operator Precedence

The precedence of an operator specifies how “tightly” it binds two expressions together. For example, in the expression 1 + 5 * 3, the answer is 16 and not 18 because the multiplication (“*”)...

Arithmetic Operators

Arithmetic Operators

Arithmetic Operators Example Name Result -$a Negation Opposite of $a. $a + $b Addition Sum of $a and $b. $a – $b Subtraction Difference of $a and $b. $a * $b Multiplication Product of...

Array Operators

Array Operators

Example Name Result $a + $b Union Union of $a and $b. $a == $b Equality TRUE if $a and $b have the same key/value pairs. $a === $b Identity TRUE if $a and...

String Operators

String Operators

There are two string operators. The first is the concatenation operator (‘.’), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator (‘.=’), which appends the argument...

Logical Operators php

Logical Operators php

Logical operators are based on logic based and or etc. Example Name Result $a and $b And TRUE if both $a and $b are TRUE. $a or $b Or TRUE if either $a or...

increment and decrement operators

increment and decrement operators

PHP supports C-style pre- and post-increment and decrement operators. Example Name Result ++$a Pre-increment Increments $a by one, then returns $a. $a++ Post-increment Returns $a, then increments $a by one. –$a Pre-decrement Decrements $a...

Comparison Operators

Comparison Operators

Comparison operators, as their name implies, allow you to compare two values. You may also be interested in viewing the type comparison tables, as they show examples of various type related comparisons. Example Name...

Bitwise Operators

Bitwise Operators

Bitwise operators allow evaluation and manipulation of specific bits within an integer. Bit shifting in PHP is arithmetic. Bits shifted off either end are discarded. Left shifts have zeros shifted in on the right...

Assignment Operators

Assignment Operators

The basic assignment operator is “=”. Your first inclination might be to think of this as “equal to”. Don’t. It really means that the left operand gets set to the value of the expression...

Introduction

Introduction

Operators are the mathematical, string, comparison, and logical commands such as plus, minus, times, and divide. PHP looks a lot like plain arithmetic; for instance, the following statement outputs 8: There are various operators...