Single Equal
It is Known as Assignment Operator means it assigns a constant value in a variable. For Example : A Constant Value (10) is assigned to the variable $num1, it prints the assigned value when echo called. See the Program Below:-
Sample Program
Output
Double Equal
It compares two variables or Operators and gives the Output whether it is True or False.
Case 1. When Both the operants have the same value then it returns True. (Note: Only Value need to be same not Datatype)
Case 2. When Both the operants have a different Value then it returns False.
Note :- It prints 1 for True and for False it can’t prints.
Sample Program
Output
Triple Equal
It compares two variables or Operators and gives Output whether it is True or False by Comparing the Value and Datatype both.
Case 1. When Both the operants have the same Value and Datatype then it returns True. (Note: It Compares Value and Datatype Both.)
Case 2. When Both the operants have the Same value but Different datatype then it returns False.
Case 3. When Both the operants have the Different value but Same datatype then it also returns False.
Case 4. When Both the operants have the Different value as well as datatype then it also returns False.
Sample Program(Case 1)
Output
Sample Program(Case 2)
Output
Sample Program(Case 3)
Output
Sample Program(Case 4)
Output
Difference between Not Equal and Not Identical in PHP.
It Compares two variable, when the variables are not equal then it returns True either False. For Example-
5!=2 (5 does not equal to 2), it returns True because 5 is not equal to 2, means statement is true. So it returns true and prints 1.
Sample Program
Output
Not Identical
It returns True if $a is not equal to $b, or they are not of the same Datatype. For Example:-
$a !==$b , It returns True when either value of $a does not equal to $b or Datatype of $a and $b are different. If any of two statements matched then it returns True.
Sample Program
Output
In the above Program, Datatype of the variables are the same but Value of variables are different (any one statement matched) So it returns True.
Spaceship Operator
It returns -1, 0, 1 when $a is respectively less than, equal to, or greater than $b. It also compares String by their ASCII value. For Example:- $a<=>$b
Sample Program(Constant Value)
Output
Sample Program(String)
Output
Click here for Next part :-
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021