SlideShare a Scribd company logo
1 of 9
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

Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 

What's hot (20)

Php
PhpPhp
Php
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Php array
Php arrayPhp array
Php array
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Php basics
Php basicsPhp basics
Php basics
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
 
Event handling
Event handlingEvent handling
Event handling
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
php
phpphp
php
 
Php string function
Php string function Php string function
Php string function
 
PHP Loops and PHP Forms
PHP  Loops and PHP FormsPHP  Loops and PHP Forms
PHP Loops and PHP Forms
 
PHP
PHPPHP
PHP
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Looping statement
Looping statementLooping statement
Looping statement
 

Similar to Operators php

Programming with php
Programming with phpProgramming with php
Programming with php
salissal
 
Php-Continuation
Php-ContinuationPhp-Continuation
Php-Continuation
lotlot
 

Similar to Operators php (20)

Php introduction
Php introductionPhp introduction
Php introduction
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Php
PhpPhp
Php
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
 
Programming with php
Programming with phpProgramming with php
Programming with php
 
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
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
 
Php-Continuation
Php-ContinuationPhp-Continuation
Php-Continuation
 
Intro to php
Intro to phpIntro to php
Intro to php
 
PHP-Part1
PHP-Part1PHP-Part1
PHP-Part1
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Unit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptxUnit-1 PHP Basic1 of the understanding of php.pptx
Unit-1 PHP Basic1 of the understanding of php.pptx
 
Chapter 5 Basic operators in programming
Chapter 5   Basic operators in programmingChapter 5   Basic operators in programming
Chapter 5 Basic operators in programming
 
Advanced php
Advanced phpAdvanced php
Advanced php
 
Php Basic
Php BasicPhp Basic
Php Basic
 

Recently uploaded

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

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