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

PPTX
Fracture
Suchithra Pv
 
PDF
Emotions 1st yr bs c
RGCN
 
PPTX
4 pics 1 word
mosteph
 
PDF
Web Security
Dr.Florence Dayana
 
PPT
Analog to digital converters, adc
Saumya Ranjan Behura
 
PDF
Operators in PHP
Vineet Kumar Saini
 
PPTX
HTML Forms
Ravinder Kamboj
 
PPTX
Pulse oxymetry
Swaroopa Beulah Perumalla
 
Fracture
Suchithra Pv
 
Emotions 1st yr bs c
RGCN
 
4 pics 1 word
mosteph
 
Web Security
Dr.Florence Dayana
 
Analog to digital converters, adc
Saumya Ranjan Behura
 
Operators in PHP
Vineet Kumar Saini
 
HTML Forms
Ravinder Kamboj
 

What's hot (20)

PPT
PHP CONDITIONAL STATEMENTS AND LOOPING.ppt
rehna9
 
PPTX
Parameter passing to_functions_in_c
ForwardBlog Enewzletter
 
PPTX
Statements and Conditions in PHP
Maruf Abdullah (Rion)
 
PDF
Php introduction
krishnapriya Tadepalli
 
PPTX
Control statements in c
Sathish Narayanan
 
PPT
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
PPT
Chapter 02 php basic syntax
Dhani Ahmad
 
PPTX
Data types in php
ilakkiya
 
PPTX
Php basics
Jamshid Hashimi
 
PPTX
Php operators
Aashiq Kuchey
 
PPTX
Operators and expressions in c language
tanmaymodi4
 
PDF
Python-03| Data types
Mohd Sajjad
 
PPT
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PDF
Class and Objects in Java
Spotle.ai
 
PPSX
Php and MySQL
Tiji Thomas
 
PPTX
Introduction to php
Taha Malampatti
 
PPT
Operators in C++
Sachin Sharma
 
PPTX
Call by value
Dharani G
 
PPT
structure and union
student
 
PHP CONDITIONAL STATEMENTS AND LOOPING.ppt
rehna9
 
Parameter passing to_functions_in_c
ForwardBlog Enewzletter
 
Statements and Conditions in PHP
Maruf Abdullah (Rion)
 
Php introduction
krishnapriya Tadepalli
 
Control statements in c
Sathish Narayanan
 
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
Chapter 02 php basic syntax
Dhani Ahmad
 
Data types in php
ilakkiya
 
Php basics
Jamshid Hashimi
 
Php operators
Aashiq Kuchey
 
Operators and expressions in c language
tanmaymodi4
 
Python-03| Data types
Mohd Sajjad
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Class and Objects in Java
Spotle.ai
 
Php and MySQL
Tiji Thomas
 
Introduction to php
Taha Malampatti
 
Operators in C++
Sachin Sharma
 
Call by value
Dharani G
 
structure and union
student
 
Ad

Similar to Operators php (20)

PPTX
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
PPTX
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
PPTX
Php introduction
Pratik Patel
 
PPTX
Learn PHP Basics
McSoftsis
 
PPTX
PHP Basics
Saraswathi Murugan
 
PPTX
Introduction to Java
yzebelle
 
PPSX
Php using variables-operators
Khem Puthea
 
PPTX
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
 
PPTX
PHP Basics
Muthuganesh S
 
PPTX
Data types and variables in php for writing
vishal choudhary
 
PPTX
data type in php and its introduction to use
vishal choudhary
 
PDF
Php
Vishnu Raj
 
ODP
OpenGurukul : Language : PHP
Open Gurukul
 
PPTX
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
PPTX
Expressions and Operators.pptx
Japneet9
 
PDF
Programming with php
salissal
 
PDF
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
pkaviya
 
PPTX
Php + my sql
Ashen Disanayaka
 
PPT
PHP variables
Siddique Ibrahim
 
PPTX
Php-Continuation
lotlot
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
Php introduction
Pratik Patel
 
Learn PHP Basics
McSoftsis
 
PHP Basics
Saraswathi Murugan
 
Introduction to Java
yzebelle
 
Php using variables-operators
Khem Puthea
 
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
 
PHP Basics
Muthuganesh S
 
Data types and variables in php for writing
vishal choudhary
 
data type in php and its introduction to use
vishal choudhary
 
OpenGurukul : Language : PHP
Open Gurukul
 
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
Expressions and Operators.pptx
Japneet9
 
Programming with php
salissal
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
pkaviya
 
Php + my sql
Ashen Disanayaka
 
PHP variables
Siddique Ibrahim
 
Php-Continuation
lotlot
 
Ad

Recently uploaded (20)

PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 

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; ?>