SlideShare a Scribd company logo
2
Most read
3
Most read
4
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)

PDF
Symbol table in compiler Design
Kuppusamy P
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PPT
Input output streams
Parthipan Parthi
 
PPT
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
PPTX
Operators in Python
Anusuya123
 
PPTX
Php.ppt
Nidhi mishra
 
PPTX
Introduction to php
shanmukhareddy dasi
 
PPTX
Group By, Order By, and Aliases in SQL
MSB Academy
 
PPT
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
PDF
Introduction to php
Anjan Banda
 
PPT
Java interfaces
Raja Sekhar
 
PPT
Class 3 - PHP Functions
Ahmed Swilam
 
PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PPTX
Database Connectivity in PHP
Taha Malampatti
 
PPTX
Linked list
Md. Afif Al Mamun
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PDF
Introduction to oops concepts
Nilesh Dalvi
 
PPT
Abstract data types
Poojith Chowdhary
 
PPTX
PHP Functions & Arrays
Henry Osborne
 
Symbol table in compiler Design
Kuppusamy P
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Input output streams
Parthipan Parthi
 
Operators in Python
Anusuya123
 
Php.ppt
Nidhi mishra
 
Introduction to php
shanmukhareddy dasi
 
Group By, Order By, and Aliases in SQL
MSB Academy
 
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
Introduction to php
Anjan Banda
 
Java interfaces
Raja Sekhar
 
Class 3 - PHP Functions
Ahmed Swilam
 
Priority Queue in Data Structure
Meghaj Mallick
 
Database Connectivity in PHP
Taha Malampatti
 
Linked list
Md. Afif Al Mamun
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
Introduction to oops concepts
Nilesh Dalvi
 
Abstract data types
Poojith Chowdhary
 
PHP Functions & Arrays
Henry Osborne
 

Similar to Operators php (20)

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

Recently uploaded (20)

PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
community health nursing question paper 2.pdf
Prince kumar
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Dimensions of Societal Planning in Commonism
StefanMz
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
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; ?>