0% found this document useful (0 votes)
3 views

php operators

The document provides an overview of operators in PHP, which are symbols or keywords used to perform operations on operands. It categorizes operators into types such as arithmetic, comparison, logical, assignment, string, array, and conditional. Additionally, it details arithmetic operators and their functions, as well as the purpose of comparison operators in evaluating relationships between operands.

Uploaded by

mdhasan.ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

php operators

The document provides an overview of operators in PHP, which are symbols or keywords used to perform operations on operands. It categorizes operators into types such as arithmetic, comparison, logical, assignment, string, array, and conditional. Additionally, it details arithmetic operators and their functions, as well as the purpose of comparison operators in evaluating relationships between operands.

Uploaded by

mdhasan.ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.1 What are Operators in PHP?

As in any programming language, PHP also has operators which are symbols
(sometimes keywords) that are predefined to perform certain commonly
required operations on one or more operands.
For example, using the expression "4 + 5" is equal to 9. Here "4" and "5" are
called operands and "+" is called an operator.

We have the following types of operators in PHP −

 Arithmetic Operators
 Comparison Operators
 Logical Operators
 Assignment Operators
 String Operators
 Array Operators
 Conditional (or Ternary Operators)

This chapter will provide an overview of how you can use these operators in
PHP. In the subsequent chapters, we will take a closer look at each of the
operators and how they work.

1.2 Arithmetic Operators in PHP

We use Arithmetic operators to perform mathematical operations like


addition, subtraction, multiplication, division, etc. on the given operands.
Arithmetic operators (excluding the increment and decrement operators)
always work on two operands, however the type of these operands should be
the same.

The following table highligts the arithmetic operators that are supported by
PHP. Assume variable "$a" holds 42 and variable "$b" holds 20 −

Operator Description

+ Adds two operands

- Subtracts second operand from the first

* Multiply both operands

/ Divide numerator by de-numerator


% Modulus Operator and remainder of after an integer division

++ Increment operator, increases integer value by one

-- Decrement operator, decreases integer value by one

Explore our latest online courses and learn new skills at your own pace.
Enroll and become a certified expert to boost your career.

1.3 Comparison Operators in PHP

You would use Comparison operators to compare two operands and find the
relationship between them. They return a Boolean value (either true or false)
based on the outcome of the comparison.

You might also like