Convert String to Blob and Blob to String in PHP

To Convert String to Blob in PHP we have to use PHP built-in functions, here is the list of PHP functions which we used,

  • ord() function
  • decbin() function
  • bindec() function
  • chr() function
How to Convert String to Blob and Blob to String in PHP
How to Convert String to Blob and Blob to String in PHP

ord() function is a PHP inbuilt function that used to convert the first character of a string to its ASCII value.

decbin() function is also a inbuilt PHP function and used to convert decimal to binary number.

Main Concept of Convert String to Blob With Example

First, convert string character to ASCII value using ord() function then convert ASCII value or decimal number to a binary value using decbin() function.

Source Code:

Output:

1010000 1001000 1010000 1000011 1001111 1000100 1000101 1010010

You can compile the complete code here: https://phpcoder.tech/php-online-editor/

Convert Blob to String With Example

Here are 2 main function which we used to convert.

bindec() function is used to convert a binary number to an integer number and this is also a PHP inbuilt function.

chr() function is used for getting the character from specified ASCII value.

Source Code:

Output:

PHPCODER

Main Points of Code

  1. To convert both we use a PHP loop for taking one by one character convert it.
  2. And we use the above main PHP inbuilt functions used to complete conversion.

I hope you will understand all the things correctly.

More about blob with MySQL: https://www.php.net/manual/en/function.fbsql-create-blob.php

Also Check:

Happy Coding..!

Was this article helpful?
YesNo
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
Posts created 178

Leave a Reply

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

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
mariobet - supertotobet - escort - milanobet giriş - gizabet giriş -
perabet giriş
- betkanyon giriş -

jojobet giriş

We are now accepting guest posting and creation of back-links.
This is default text for notification bar