Operator Bitwise Pada Pemrograman PHP
Perhatikan tabel dibawah:
| Operator | Keterangan | Dalam Decimal | Dalam Binner | 
|---|---|---|---|
| & | and |   9 8 & 8  | 
          1001 1000 & 1000  | 
       
| | | or |  9 8 | 8  | 
          1001 1000 | 1001  | 
       
| ^ | xor |  9 8 ^ 1  | 
          1001 1000 ^ 0001  | 
       
| ~ | not |  ~ 9 (desimal) = - 11 (desimal)  | 
         |
| << | sift left |  9 <<1 =18  | 
  |
| >> | sift right |  9  >> 1 =4  | 
  
Contoh Operator and
<!DOCTYPE html>  
 <html>  
 <body>  
 <?php   
 $x=13;   
 $y=22;   
 echo $x & $y;   
 ?>   
 </body>  
 </html>  
Contoh Operatoror or
<!DOCTYPE html>  
 <html>  
 <body>  
   <?php   
   $x=5;   
   $y=11;   
   echo $x | $y;   
   ?>   
 </body>  
 </html>  
Contoh Operator xor
<!DOCTYPE html>  
 <html>  
 <body>  
 <?php   
 $x=12;   
 $y=11;   
 echo $x ^ $y;   
 ?>    
 </body>  
 </html>  
Contoh Operator not
<!DOCTYPE html>  
 <html>  
 <body>  
 <?php   
 $x=12;   
 $y=10;   
 echo $x & ~ $y;   
 ?>  
 </body>  
 </html>  
Contoh Operator shift left
<!DOCTYPE html>  
 <html>  
 <body>  
 <?php   
 $x=8;   
 $y=3;   
 echo $x << $y;   
 ?>  
 </body>  
 </html>  
Contoh Operator shift right
<!DOCTYPE html>  
 <html>  
 <body>  
 <?php   
 $x=8;   
 $y=3;   
 echo $x >> $y;   
 ?>  
 </body>  
 </html>  
Baca Juga Operator Assignment Dalam Pemrograman PHP
Demikian Pengertian dan Contoh Operator Bitwise Pada Pemrograman PHP, Semoga Bermanfaat.
