SlideShare a Scribd company logo
2
PHP Operators
 Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
 Arithmetic operators
 Assignment operators
 Comparison operators
 Increment/Decrement operators
 Logical operators
 String operators
 Array operators
 Conditional assignment operators
Most read
3
PHP Arithmetic Operators
 The PHP arithmetic operators are used with numeric values to perform common
arithmetical operations, such as addition, subtraction, multiplication etc.
Operator Name Example Result
 + Addition $x + $y Sum of $x and $y
 - Subtraction $x - $y Difference of $x and $y
 * Multiplication $x * $y Product of $x and $y
 / Division $x / $y Quotient of $x and $y
 % Modulus $x % $y Remainder of $x divided by $y
 ** Exponentiation $x ** $y Result of raising $x to the $y'th power
Most read
4
PHP Assignment Operators
 The PHP assignment operators are used with numeric values to write a value to a
variable.
 The basic assignment operator in PHP is "=". It means that the left operand gets set to
the value of the assignment expression on the right.
Assignment Same as... Description
 x = y x = y The left operand gets set to the value of the
expression on the right
 x += y x = x + y Addition & assignment
 x -= y x = x – y Subtraction & assignment
 x *= y x = x * y Multiplication & assignment
 x /= y x = x / y Division & assignment
 x %= y x = x % y Modulus & assignment
Most read
Chandni P M
Asst. Professor, Dept. of Computer Science
R Sankar SNDP Yogam College, Koyilandy
Operators of PHP
PHP Operators
 Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
 Arithmetic operators
 Assignment operators
 Comparison operators
 Increment/Decrement operators
 Logical operators
 String operators
 Array operators
 Conditional assignment operators
PHP Arithmetic Operators
 The PHP arithmetic operators are used with numeric values to perform common
arithmetical operations, such as addition, subtraction, multiplication etc.
Operator Name Example Result
 + Addition $x + $y Sum of $x and $y
 - Subtraction $x - $y Difference of $x and $y
 * Multiplication $x * $y Product of $x and $y
 / Division $x / $y Quotient of $x and $y
 % Modulus $x % $y Remainder of $x divided by $y
 ** Exponentiation $x ** $y Result of raising $x to the $y'th power
PHP Assignment Operators
 The PHP assignment operators are used with numeric values to write a value to a
variable.
 The basic assignment operator in PHP is "=". It means that the left operand gets set to
the value of the assignment expression on the right.
Assignment Same as... Description
 x = y x = y The left operand gets set to the value of the
expression on the right
 x += y x = x + y Addition & assignment
 x -= y x = x – y Subtraction & assignment
 x *= y x = x * y Multiplication & assignment
 x /= y x = x / y Division & assignment
 x %= y x = x % y Modulus & assignment
PHP Comparison Operators
The PHP comparison operators are used to compare two values (number or string):
Operator Name Example Result
 == Equal $x == $y Returns true if $x is equal to $y
 === Identical $x === $y Returns true if $x is equal to $y, and they are
of the same type
 != Not equal $x != $y Returns true if $x is not equal to $y
 <> Not equal $x <> $y Returns true if $x is not equal to $y
 !== Not identical $x !== $y Returns true if $x is not equal to $y, or they
are not of the same type
 > Greater than $x > $y Returns true if $x is greater than $y
 < Less than $x < $y Returns true if $x is less than $y
 >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y
 <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y
 ?: Ternary/Conditional Operator $big =($x>$y)?$x:$y
PHP Increment / Decrement Operators
 The PHP increment operators are used to increment a variable's value.
 The PHP decrement operators are used to decrement a variable's value.
Operator Name Description
 ++$x Pre-increment Increments $x by one, then returns $x
 $x++ Post-increment Returns $x, then increments $x by one
 --$x Pre-decrement Decrements $x by one, then returns $x
 $x-- Post-decrement Returns $x, then decrements $x by one
PHP Logical Operators
 The PHP logical operators are used to combine conditional statements.
Operator Name Example Result
 and And $x and $y True if both $x and $y are true
 or Or $x or $y True if either $x or $y is true
 xor Xor $x xor $y True if either $x or $y is true, but not both
 && And $x && $y True if both $x and $y are true
 || Or $x || $y True if either $x or $y is true
 ! Not !$x True if $x is not true
 << Shift left $x<<$y Shift the bits of $x , $y steps to the left
 >> Shift right $x>>$y Shift the bits of $x , $y steps to the right
PHP String Operators
 PHP has two operators that are specially designed for strings.
Operator Name Example Result
. Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2
.= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1
<?php
$x = “Good “;
$y = “Morning”;
Echo $x.$y;
$x.=$y;
Echo $x;
?>
Operators php

More Related Content

What's hot (20)

Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
Vineet Kumar Saini
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
Computer Hardware & Trouble shooting
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
Php
PhpPhp
Php
Shyam Khant
 
PHP
PHPPHP
PHP
Steve Fort
 
Php introduction
Php introductionPhp introduction
Php introduction
krishnapriya Tadepalli
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
php
phpphp
php
ajeetjhajharia
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Anjan Banda
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
Spy Seat
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
Taha Malampatti
 
Php array
Php arrayPhp array
Php array
Nikul Shah
 
Functions in PHP.pptx
Functions in PHP.pptxFunctions in PHP.pptx
Functions in PHP.pptx
Japneet9
 
Dom
DomDom
Dom
Rakshita Upadhyay
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
Compare Infobase Limited
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 

Similar to Operators php (20)

Lesson 5 php operators
Lesson 5   php operatorsLesson 5   php operators
Lesson 5 php operators
MLG College of Learning, Inc
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
Japneet9
 
Php introduction
Php introductionPhp introduction
Php introduction
Pratik Patel
 
PHP-Part1
PHP-Part1PHP-Part1
PHP-Part1
Ahmed Saihood
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
Intoroduction to Adnvanced Internet Programming Chapter two.pptxIntoroduction to Adnvanced Internet Programming Chapter two.pptx
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
McSoftsis
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
CSS & PHP10101010110101010101010100.pdf
CSS  & PHP10101010110101010101010100.pdfCSS  & PHP10101010110101010101010100.pdf
CSS & PHP10101010110101010101010100.pdf
sithumMarasighe
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Saraswathi Murugan
 
Chapter 5Internet Programming one PHP.pptx
Chapter 5Internet Programming one PHP.pptxChapter 5Internet Programming one PHP.pptx
Chapter 5Internet Programming one PHP.pptx
abduwasiahmed
 
Unit IV.pptx Server side scripting PHP IT3401
Unit IV.pptx Server side scripting PHP IT3401Unit IV.pptx Server side scripting PHP IT3401
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
 
Intro to php
Intro to phpIntro to php
Intro to php
NithyaNithyav
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
pkaviya
 
Php
PhpPhp
Php
Vishnu Raj
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Muthuganesh S
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
Japneet9
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP nPHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
Intoroduction to Adnvanced Internet Programming Chapter two.pptxIntoroduction to Adnvanced Internet Programming Chapter two.pptx
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
McSoftsis
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
CSS & PHP10101010110101010101010100.pdf
CSS  & PHP10101010110101010101010100.pdfCSS  & PHP10101010110101010101010100.pdf
CSS & PHP10101010110101010101010100.pdf
sithumMarasighe
 
Chapter 5Internet Programming one PHP.pptx
Chapter 5Internet Programming one PHP.pptxChapter 5Internet Programming one PHP.pptx
Chapter 5Internet Programming one PHP.pptx
abduwasiahmed
 
Unit IV.pptx Server side scripting PHP IT3401
Unit IV.pptx Server side scripting PHP IT3401Unit IV.pptx Server side scripting PHP IT3401
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
pkaviya
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
Ad

Recently uploaded (20)

SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
Julián Jesús Pérez Fernández
 
Critical Thinking and Bias with Jibi Moses
Critical Thinking and Bias with Jibi MosesCritical Thinking and Bias with Jibi Moses
Critical Thinking and Bias with Jibi Moses
Excellence Foundation for South Sudan
 
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSELET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
OlgaLeonorTorresSnch
 
Order Lepidoptera: Butterflies and Moths.pptx
Order Lepidoptera: Butterflies and Moths.pptxOrder Lepidoptera: Butterflies and Moths.pptx
Order Lepidoptera: Butterflies and Moths.pptx
Arshad Shaikh
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910
PankajRodey1
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
Writing Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research CommunityWriting Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research Community
Rishi Bankim Chandra Evening College, Naihati, North 24 Parganas, West Bengal, India
 
How to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time OffHow to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time Off
Celine George
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Order: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptxOrder: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptx
Arshad Shaikh
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar SirPHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
Diwakar Kashyap
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSELET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
LET´S PRACTICE GRAMMAR USING SIMPLE PAST TENSE
OlgaLeonorTorresSnch
 
Order Lepidoptera: Butterflies and Moths.pptx
Order Lepidoptera: Butterflies and Moths.pptxOrder Lepidoptera: Butterflies and Moths.pptx
Order Lepidoptera: Butterflies and Moths.pptx
Arshad Shaikh
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910
PankajRodey1
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
How to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time OffHow to Create Time Off Request in Odoo 18 Time Off
How to Create Time Off Request in Odoo 18 Time Off
Celine George
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Order: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptxOrder: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptx
Arshad Shaikh
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar SirPHYSIOLOGY & SPORTS INJURY by Diwakar Sir
PHYSIOLOGY & SPORTS INJURY by Diwakar Sir
Diwakar Kashyap
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
Ad

Operators php

  • 1. Chandni P M Asst. Professor, Dept. of Computer Science R Sankar SNDP Yogam College, Koyilandy Operators of PHP
  • 2. PHP Operators  Operators are used to perform operations on variables and values. PHP divides the operators in the following groups:  Arithmetic operators  Assignment operators  Comparison operators  Increment/Decrement operators  Logical operators  String operators  Array operators  Conditional assignment operators
  • 3. PHP Arithmetic Operators  The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc. Operator Name Example Result  + Addition $x + $y Sum of $x and $y  - Subtraction $x - $y Difference of $x and $y  * Multiplication $x * $y Product of $x and $y  / Division $x / $y Quotient of $x and $y  % Modulus $x % $y Remainder of $x divided by $y  ** Exponentiation $x ** $y Result of raising $x to the $y'th power
  • 4. PHP Assignment Operators  The PHP assignment operators are used with numeric values to write a value to a variable.  The basic assignment operator in PHP is "=". It means that the left operand gets set to the value of the assignment expression on the right. Assignment Same as... Description  x = y x = y The left operand gets set to the value of the expression on the right  x += y x = x + y Addition & assignment  x -= y x = x – y Subtraction & assignment  x *= y x = x * y Multiplication & assignment  x /= y x = x / y Division & assignment  x %= y x = x % y Modulus & assignment
  • 5. PHP Comparison Operators The PHP comparison operators are used to compare two values (number or string): Operator Name Example Result  == Equal $x == $y Returns true if $x is equal to $y  === Identical $x === $y Returns true if $x is equal to $y, and they are of the same type  != Not equal $x != $y Returns true if $x is not equal to $y  <> Not equal $x <> $y Returns true if $x is not equal to $y  !== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not of the same type  > Greater than $x > $y Returns true if $x is greater than $y  < Less than $x < $y Returns true if $x is less than $y  >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y  <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y  ?: Ternary/Conditional Operator $big =($x>$y)?$x:$y
  • 6. PHP Increment / Decrement Operators  The PHP increment operators are used to increment a variable's value.  The PHP decrement operators are used to decrement a variable's value. Operator Name Description  ++$x Pre-increment Increments $x by one, then returns $x  $x++ Post-increment Returns $x, then increments $x by one  --$x Pre-decrement Decrements $x by one, then returns $x  $x-- Post-decrement Returns $x, then decrements $x by one
  • 7. PHP Logical Operators  The PHP logical operators are used to combine conditional statements. Operator Name Example Result  and And $x and $y True if both $x and $y are true  or Or $x or $y True if either $x or $y is true  xor Xor $x xor $y True if either $x or $y is true, but not both  && And $x && $y True if both $x and $y are true  || Or $x || $y True if either $x or $y is true  ! Not !$x True if $x is not true  << Shift left $x<<$y Shift the bits of $x , $y steps to the left  >> Shift right $x>>$y Shift the bits of $x , $y steps to the right
  • 8. PHP String Operators  PHP has two operators that are specially designed for strings. Operator Name Example Result . Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2 .= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1 <?php $x = “Good “; $y = “Morning”; Echo $x.$y; $x.=$y; Echo $x; ?>