- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How does the bin2hex() function work in PHP?
It is a function that helps in converting a string into a hexadecimal value. It is done byte wise and the high nibbled bytes are converted first.
Syntax of bin2hex() function
bin2hex($string)
It takes in a string and converts the string to a hexadecimal representation.
Example
<?php $my_str1 = "This"; $my_str2 = "is"; $my_str3 = "a"; $my_str4 = "sample"; print(bin2hex($my_str1)); echo "<br>"; print(bin2hex($my_str2)); echo "<br>"; print(bin2hex($my_str3)); echo "<br>"; print(bin2hex($my_str4)); ?>
Output
54686973 6973 61 73616d706c65
Within the <php> tags, the bin2hex function is called on 4 elements which are previously defined. Then, the result of calling the bin2hex function on each of the string is displayed on the console.
- Related Articles
- bin2hex() function in PHP
- How does the array_diff_key() work in PHP?
- How does issubclass() function work in Python?
- How does isinstance() function work in Python?
- How does recursion function work in JavaScript?
- How does MySQL IF() function work?
- How does MySQL QUOTE() function work with comparison values?
- How does the magnets work?
- How does the Microstrip antenna work?
- How does the Selenium WebDriver work?
- How does the discordancy testing work?
- How does the WannaCry malware work?
- How does the Docker network work?
- How does jQuery.scrollTop() work?
- How does jQuery.scrollLeft() work?

Advertisements