SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
Operators in PHP

Introduction

Operators are a special type of symbols, which are used for calculation and comparison in a
programming language. Operators are also used to operate on values. There are six types
operators in PHP, which are as follows:

      Arithmetic Operators
      Assignment Operators
      Comparison Operators
      Logical Operators
      Increment/Decrement Operators
      Conditional Operators

Arithmetic Operator

These operators are used for calculation like add, subtraction, multiplication, division and
modulation.

      Plus Operator (+) :- This operator is used for add two or more numbers. This is
       known as addition operator.
      Minus Operator (-) :- This operator is used for subtract two more numbers. This
       operator is known as subtraction operator.
      Multiplication Operator (*) :- This operator is used for find the product of two or
       more numbers.
      Division Operator (/) :- This operator is used for find the quotient of two numbers.
      Modulus Operator (%) :- This operator is used to find the quotient and remainder of
       two numbers.

Examples of arithmetic operators are as follows:

<?php
$x=5;
$y=2;
$addition=$x+$y; //add two number
$subtraction=$x-$y; //subtract two number
$multiplication=$x*$y; //multiply two number
$division=$x/$y; //divide two numbers
$modulus=$x%$y; //modulus two numbers
echo "The addition is :" .$addition.'<br>';
echo "The subtraction is :" .$subtraction.'<br>';
echo "The multiplication is :".$multiplication.'<br>';
echo "The division is :".$division.'<br>';
echo "The modulus is :".$modulus.'<br>';
?>

Output



                       www.vineetsaini.wordpress.com
Assignment Operators

The assignment operators are used to set a variable equal to a value or set a variable to
another variable's value. This operator is denoted by the (equal) "=" sign. There are many
types of assignment operators in PHP, which are as follows.

      = :- This operator is used for assign the value to the variable. e.g. x=5.
      += :- This operator is used for assign the value and add the value to the variable.
       e.g. x+=5 i.e. x=x+5.
      -= :- This operator is used for assign the value and subtract the value to the
       variable. e.g. x-=5 i.e. x=x-5.
      *= :- This operator is used for assign the value and multiply the value to the
       variable. e.g. x*=5 i.e. x=x*5.
      /= :- This operator is used for assign the value to the variable and find the quotient.
       e.g. x/=5 i.e. x=x/5.
      %= :- This operator is used for assign the value to the variable and find the
       modulation i.e. remainder and quotient. e.g. x%=5 i.e. x=x%5.
      .= :- This operator is used for assign the value to the variable and add the new value
       in the variable.

Examples of assignment operators are as follows:

<?php
$x=5;
$x+=5; //x=x+5 i.e. x=5+5=10
echo "The value of x is :".$x.'<br>';
$y=8;
$y-=5; //y=y-5 i.e. y=8-5=3
echo "The value of y is :".$y.'<br>';
$z=2;
$z*=3; //z=z*3 i.e. z=2*3=6
echo "The value of z is :".$z.'<br>';
$p=7;
$p/=2; // p=p/2 i.e. p=7/2=3.5



                      www.vineetsaini.wordpress.com
echo "The value of p is :".$p.'<br>';
$q=8;
$q%=3; //q=q%3 i.e. q=8%3=2 (remainder)
echo "The value of q is :".$q.'<br>';
?>

Output




Decision Statement (if...else)

Before discussing comparison operators I will discuss the decision statement. A decision
statement is represented by if...else. A decision statement has two parts i.e. one is if and
second is else.
If is the part of a decision statement where we supply a condition and it has a block of
commands that execute when the condition is true.
The second part of the decision statement is else which has commands and executes when
the condition is false.

Syntax of if...else

 if (expression)
  {
      true;
  }
 else
  {
     false;
   }

Comparison Operators

Comparison operators are used to check the relationship between variables and values.
There are many types of comparison operators in PHP, which are as follows:



                      www.vineetsaini.wordpress.com
   == :- This operator is known as equal to operator. e.g. 5==5 i.e. return true.
      != :- This operator is known as not equal to operator. e.g. 5!=5 return false.
      < :- This operator is known as less than operator. e.g. 5<5 return false.
      > :- This operator is known as greater than operator. e.g. 5>5 return false.
      <= :- This operator is known as less than equal to operator. e.g. 5<=2 return
       false.
      >= :- This operator is known as greater than equal to operator. e.g. 5>=2 return
       true.

Examples of comparison operators are as follows:

<?php
$x=5;
$y=2;
if($x==$y)
{
echo "x is equal to y i.e. True".'<br>';
}
else
{
echo "x is not equal to y i.e. False".'<br>';
}
if($x<$y)
{
echo "x is less than y i.e. True".'<br>';
}
else
{
echo "x is not less than y i.e. False".'<br>';
}
echo "Same as you can use other comparison operator ";
?>

Output




                     www.vineetsaini.wordpress.com
Logical Operators

Logical operators are used to convert the operands to Boolean values and then perform a
respective comparison. There are many types of logical operators in PHP, which are as
follows:

      && :- This operator is known as logical and operator.
      || : This operator is known as logical or operator.
      ! :- This operator is known as logical not operator.

Examples of logical operators are as follows:


<?php
$x=5;
$y=5;
if($x&&$y) //logical and operator
{
echo "True".'<br>';
}
else
{
echo "False".'<br>';
}
if($x||$y) //logical or operator
{
echo "True".'<br>';
}
else
{
echo "False".'<br>';
}
if($x!=$y) //logical not operator
{
echo "True".'<br>';
}
else
{
echo "False".'<br>';
}
?>

Output




                      www.vineetsaini.wordpress.com
Increment/Decrement Operators

Increment/Decrement is a special type of operator. The Increment operator increases the
value of an operand by 1. The Decrement operator decreases the value of an operand by 1.
There are two types of increment/decrement operators which are as follows:

      Prefix Increment/Decrement operator
      Postfix Increment/Decrement operator

Examples of Increment/Decrement operators are as follows:

<?php
$x=5;
$y=$x++; // postfix increment operator
$z=++$x; // prefix increment operator
$a=$x--; // postfix decrement operator
$b=--$x; // prefix decrement operator
echo "The value of x in postfix increment operator is : " .$y.'<br>';
echo "The value of x in prefix increment operator is :".$z.'<br>';
echo "The value of x in postfix decrement operator is :".$a.'<br>';
echo "The value of x in prefix decrement operator is :" .$b.'<br>';
?>

Output




                      www.vineetsaini.wordpress.com
Conditional Operators

The Conditional operator is a special type of operator which is conditional. There are two
expressions in a conditional operator. If condition one is true then return expression 1
otherwise return expression 2.

Syntax of Conditional Operator

condition ? exp1 : exp 2 ;

Examples of the Conditional operator are as follows:

<?php
$x=5;
$y=6;
$z=($x>$y) ? 'True' : 'False' ;
echo $z;
?>

Output




                       www.vineetsaini.wordpress.com
Conclusion

So in this article you saw the types of operators and how to use these operators in PHP.




                     www.vineetsaini.wordpress.com

More Related Content

What's hot (20)

PPSX
Php and MySQL
Tiji Thomas
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PDF
javascript objects
Vijay Kalyan
 
PPTX
Vectors in Java
Abhilash Nair
 
PPT
Chapter 02 php basic syntax
Dhani Ahmad
 
PPT
Menu bars and menus
myrajendra
 
PPTX
Operators php
Chandni Pm
 
PPTX
Css selectors
Parth Trivedi
 
PPTX
Php string function
Ravi Bhadauria
 
PPTX
Validation Controls in asp.net
Deep Patel
 
PPT
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PDF
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
PPTX
Php operators
Aashiq Kuchey
 
PPTX
Loops PHP 04
mohamedsaad24
 
PPTX
css.ppt
bhasula
 
PPTX
Database Connectivity in PHP
Taha Malampatti
 
PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPT
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
PDF
Regular expression in javascript
Toan Nguyen
 
PPT
PHP variables
Siddique Ibrahim
 
Php and MySQL
Tiji Thomas
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
javascript objects
Vijay Kalyan
 
Vectors in Java
Abhilash Nair
 
Chapter 02 php basic syntax
Dhani Ahmad
 
Menu bars and menus
myrajendra
 
Operators php
Chandni Pm
 
Css selectors
Parth Trivedi
 
Php string function
Ravi Bhadauria
 
Validation Controls in asp.net
Deep Patel
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Php operators
Aashiq Kuchey
 
Loops PHP 04
mohamedsaad24
 
css.ppt
bhasula
 
Database Connectivity in PHP
Taha Malampatti
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
Regular expression in javascript
Toan Nguyen
 
PHP variables
Siddique Ibrahim
 

Similar to Operators in PHP (20)

PPTX
Lesson 5 php operators
MLG College of Learning, Inc
 
PPTX
Expressions and Operators.pptx
Japneet9
 
PPTX
Chapter 5Internet Programming one PHP.pptx
abduwasiahmed
 
PPTX
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
PPTX
Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
 
PDF
Php
Vishnu Raj
 
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
 
PPTX
Php introduction
Pratik Patel
 
PPTX
Php + my sql
Ashen Disanayaka
 
PPTX
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
PDF
CSS & PHP10101010110101010101010100.pdf
sithumMarasighe
 
PDF
PHP-Part1
Ahmed Saihood
 
PPTX
Intro to php
NithyaNithyav
 
PPTX
PHP Basics
Saraswathi Murugan
 
PPTX
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
PPTX
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
PPTX
PHP Basics
Muthuganesh S
 
PPTX
Variables, Operators, Arrays, Loops (lecture 2).pptx
abpassion478
 
Lesson 5 php operators
MLG College of Learning, Inc
 
Expressions and Operators.pptx
Japneet9
 
Chapter 5Internet Programming one PHP.pptx
abduwasiahmed
 
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
 
Php introduction
Pratik Patel
 
Php + my sql
Ashen Disanayaka
 
PHP PPT.pptxPHP PPT.pptxPHP PPT.pptxPHP n
ArtiRaju1
 
CSS & PHP10101010110101010101010100.pdf
sithumMarasighe
 
PHP-Part1
Ahmed Saihood
 
Intro to php
NithyaNithyav
 
PHP Basics
Saraswathi Murugan
 
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
Unit IV.pptx Server side scripting PHP IT3401
lakshitakumar291
 
PHP Basics
Muthuganesh S
 
Variables, Operators, Arrays, Loops (lecture 2).pptx
abpassion478
 
Ad

More from Vineet Kumar Saini (20)

PDF
Abstract Class and Interface in PHP
Vineet Kumar Saini
 
PDF
Add edit delete in Codeigniter in PHP
Vineet Kumar Saini
 
PDF
Introduction to Html
Vineet Kumar Saini
 
PDF
Computer Fundamentals
Vineet Kumar Saini
 
PDF
Country State City Dropdown in PHP
Vineet Kumar Saini
 
PDF
Pagination in PHP
Vineet Kumar Saini
 
PDF
Stripe in php
Vineet Kumar Saini
 
PDF
Php Tutorials for Beginners
Vineet Kumar Saini
 
PDF
Install Drupal on Wamp Server
Vineet Kumar Saini
 
PDF
Joomla 2.5 Tutorial For Beginner PDF
Vineet Kumar Saini
 
PDF
Functions in PHP
Vineet Kumar Saini
 
PDF
Sorting arrays in PHP
Vineet Kumar Saini
 
PDF
Dropdown List in PHP
Vineet Kumar Saini
 
PDF
Update statement in PHP
Vineet Kumar Saini
 
PDF
Delete statement in PHP
Vineet Kumar Saini
 
PDF
Implode & Explode in PHP
Vineet Kumar Saini
 
PDF
Types of Error in PHP
Vineet Kumar Saini
 
PDF
GET and POST in PHP
Vineet Kumar Saini
 
PDF
Database connectivity in PHP
Vineet Kumar Saini
 
PDF
Arrays in PHP
Vineet Kumar Saini
 
Abstract Class and Interface in PHP
Vineet Kumar Saini
 
Add edit delete in Codeigniter in PHP
Vineet Kumar Saini
 
Introduction to Html
Vineet Kumar Saini
 
Computer Fundamentals
Vineet Kumar Saini
 
Country State City Dropdown in PHP
Vineet Kumar Saini
 
Pagination in PHP
Vineet Kumar Saini
 
Stripe in php
Vineet Kumar Saini
 
Php Tutorials for Beginners
Vineet Kumar Saini
 
Install Drupal on Wamp Server
Vineet Kumar Saini
 
Joomla 2.5 Tutorial For Beginner PDF
Vineet Kumar Saini
 
Functions in PHP
Vineet Kumar Saini
 
Sorting arrays in PHP
Vineet Kumar Saini
 
Dropdown List in PHP
Vineet Kumar Saini
 
Update statement in PHP
Vineet Kumar Saini
 
Delete statement in PHP
Vineet Kumar Saini
 
Implode & Explode in PHP
Vineet Kumar Saini
 
Types of Error in PHP
Vineet Kumar Saini
 
GET and POST in PHP
Vineet Kumar Saini
 
Database connectivity in PHP
Vineet Kumar Saini
 
Arrays in PHP
Vineet Kumar Saini
 
Ad

Recently uploaded (20)

PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Dimensions of Societal Planning in Commonism
StefanMz
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 

Operators in PHP

  • 1. Operators in PHP Introduction Operators are a special type of symbols, which are used for calculation and comparison in a programming language. Operators are also used to operate on values. There are six types operators in PHP, which are as follows:  Arithmetic Operators  Assignment Operators  Comparison Operators  Logical Operators  Increment/Decrement Operators  Conditional Operators Arithmetic Operator These operators are used for calculation like add, subtraction, multiplication, division and modulation.  Plus Operator (+) :- This operator is used for add two or more numbers. This is known as addition operator.  Minus Operator (-) :- This operator is used for subtract two more numbers. This operator is known as subtraction operator.  Multiplication Operator (*) :- This operator is used for find the product of two or more numbers.  Division Operator (/) :- This operator is used for find the quotient of two numbers.  Modulus Operator (%) :- This operator is used to find the quotient and remainder of two numbers. Examples of arithmetic operators are as follows: <?php $x=5; $y=2; $addition=$x+$y; //add two number $subtraction=$x-$y; //subtract two number $multiplication=$x*$y; //multiply two number $division=$x/$y; //divide two numbers $modulus=$x%$y; //modulus two numbers echo "The addition is :" .$addition.'<br>'; echo "The subtraction is :" .$subtraction.'<br>'; echo "The multiplication is :".$multiplication.'<br>'; echo "The division is :".$division.'<br>'; echo "The modulus is :".$modulus.'<br>'; ?> Output www.vineetsaini.wordpress.com
  • 2. Assignment Operators The assignment operators are used to set a variable equal to a value or set a variable to another variable's value. This operator is denoted by the (equal) "=" sign. There are many types of assignment operators in PHP, which are as follows.  = :- This operator is used for assign the value to the variable. e.g. x=5.  += :- This operator is used for assign the value and add the value to the variable. e.g. x+=5 i.e. x=x+5.  -= :- This operator is used for assign the value and subtract the value to the variable. e.g. x-=5 i.e. x=x-5.  *= :- This operator is used for assign the value and multiply the value to the variable. e.g. x*=5 i.e. x=x*5.  /= :- This operator is used for assign the value to the variable and find the quotient. e.g. x/=5 i.e. x=x/5.  %= :- This operator is used for assign the value to the variable and find the modulation i.e. remainder and quotient. e.g. x%=5 i.e. x=x%5.  .= :- This operator is used for assign the value to the variable and add the new value in the variable. Examples of assignment operators are as follows: <?php $x=5; $x+=5; //x=x+5 i.e. x=5+5=10 echo "The value of x is :".$x.'<br>'; $y=8; $y-=5; //y=y-5 i.e. y=8-5=3 echo "The value of y is :".$y.'<br>'; $z=2; $z*=3; //z=z*3 i.e. z=2*3=6 echo "The value of z is :".$z.'<br>'; $p=7; $p/=2; // p=p/2 i.e. p=7/2=3.5 www.vineetsaini.wordpress.com
  • 3. echo "The value of p is :".$p.'<br>'; $q=8; $q%=3; //q=q%3 i.e. q=8%3=2 (remainder) echo "The value of q is :".$q.'<br>'; ?> Output Decision Statement (if...else) Before discussing comparison operators I will discuss the decision statement. A decision statement is represented by if...else. A decision statement has two parts i.e. one is if and second is else. If is the part of a decision statement where we supply a condition and it has a block of commands that execute when the condition is true. The second part of the decision statement is else which has commands and executes when the condition is false. Syntax of if...else if (expression) { true; } else { false; } Comparison Operators Comparison operators are used to check the relationship between variables and values. There are many types of comparison operators in PHP, which are as follows: www.vineetsaini.wordpress.com
  • 4. == :- This operator is known as equal to operator. e.g. 5==5 i.e. return true.  != :- This operator is known as not equal to operator. e.g. 5!=5 return false.  < :- This operator is known as less than operator. e.g. 5<5 return false.  > :- This operator is known as greater than operator. e.g. 5>5 return false.  <= :- This operator is known as less than equal to operator. e.g. 5<=2 return false.  >= :- This operator is known as greater than equal to operator. e.g. 5>=2 return true. Examples of comparison operators are as follows: <?php $x=5; $y=2; if($x==$y) { echo "x is equal to y i.e. True".'<br>'; } else { echo "x is not equal to y i.e. False".'<br>'; } if($x<$y) { echo "x is less than y i.e. True".'<br>'; } else { echo "x is not less than y i.e. False".'<br>'; } echo "Same as you can use other comparison operator "; ?> Output www.vineetsaini.wordpress.com
  • 5. Logical Operators Logical operators are used to convert the operands to Boolean values and then perform a respective comparison. There are many types of logical operators in PHP, which are as follows:  && :- This operator is known as logical and operator.  || : This operator is known as logical or operator.  ! :- This operator is known as logical not operator. Examples of logical operators are as follows: <?php $x=5; $y=5; if($x&&$y) //logical and operator { echo "True".'<br>'; } else { echo "False".'<br>'; } if($x||$y) //logical or operator { echo "True".'<br>'; } else { echo "False".'<br>'; } if($x!=$y) //logical not operator { echo "True".'<br>'; } else { echo "False".'<br>'; } ?> Output www.vineetsaini.wordpress.com
  • 6. Increment/Decrement Operators Increment/Decrement is a special type of operator. The Increment operator increases the value of an operand by 1. The Decrement operator decreases the value of an operand by 1. There are two types of increment/decrement operators which are as follows:  Prefix Increment/Decrement operator  Postfix Increment/Decrement operator Examples of Increment/Decrement operators are as follows: <?php $x=5; $y=$x++; // postfix increment operator $z=++$x; // prefix increment operator $a=$x--; // postfix decrement operator $b=--$x; // prefix decrement operator echo "The value of x in postfix increment operator is : " .$y.'<br>'; echo "The value of x in prefix increment operator is :".$z.'<br>'; echo "The value of x in postfix decrement operator is :".$a.'<br>'; echo "The value of x in prefix decrement operator is :" .$b.'<br>'; ?> Output www.vineetsaini.wordpress.com
  • 7. Conditional Operators The Conditional operator is a special type of operator which is conditional. There are two expressions in a conditional operator. If condition one is true then return expression 1 otherwise return expression 2. Syntax of Conditional Operator condition ? exp1 : exp 2 ; Examples of the Conditional operator are as follows: <?php $x=5; $y=6; $z=($x>$y) ? 'True' : 'False' ; echo $z; ?> Output www.vineetsaini.wordpress.com
  • 8. Conclusion So in this article you saw the types of operators and how to use these operators in PHP. www.vineetsaini.wordpress.com