Horje Website
PHP Convert a Decimal Number to Hexadecimal and Vice Versa – Learn Convert a decimal number to hexadecimal and vice versa – PHP Code

PHP Convert a Decimal Number to Hexadecimal and Vice Versa – Learn Convert a decimal number to hexadecimal and vice versa

PHP Convert a Decimal Number to Hexadecimal and Vice Versa - Learn Convert a decimal number to hexadecimal and vice versa - PHP Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>PHP Convert a Decimal Number to Hexadecimal and Vice Versa</title>
  5. </head>
  6. <body>
  7. <?php
  8. // Convert decimal to hexadecimal
  9. echo dechex(255) . "<br>"; // 0utputs: ff
  10. echo dechex(196) . "<br>"; // 0utputs: c4
  11. echo dechex(0) . "<br>"; // 0utputs: 0
  12. // Convert hexadecimal to decimal
  13. echo hexdec('ff') . "<br>"; // 0utputs: 255
  14. echo hexdec('c4') . "<br>"; // 0utputs: 196
  15. echo hexdec(0) . "<br>"; // 0utputs: 0
  16. ?>
  17. </body>
  18. </html>



Try Your Self ->



Published:
September 25, 2020
Author:
admin
Category:
PHP Basic, PHP Source Code
Views:
22

This article was posted in PHP Basic, PHP Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2023