- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the significance of ‘^’ in PHP?
The ‘^’ is a bitwise operator in PHP, i.e XOR (exclusive OR) bitwise operator, that is used to display the ASCII values of variables in question. For example − For evert bit in the value, the ^ operator checks if that bit is the same in the other value too. If the values are same, 0 is produced as an output, otherwise 1 is shown as output. Below is an example illustrating the same −
Example
<?php $x = "a"; $y = "b"; $x ^= $y; $y ^= $x; $x ^= $y; echo $x; echo "
"; echo $y; ?>
Output
b a
Different variables are assigned character values and the ‘^’ operator is used to perform XOR on the two variables. Relevant output is displayed on the console.
Advertisements