0

I have a code like this:

CONVERT(binary, 'Hello World!')

Is it possible to convert that into pure php code?

This trick didn't work:

$data = (binary) 'Hello World!';

I want the output similar to this:

0x316B646A666762663100000000
Ronnel Martinez
  • 135
  • 4
  • 15
  • Does this answer your question? [PHP convert string to hex and hex to string](https://stackoverflow.com/q/14674834/2029983) – Thom A Jul 17 '20 at 09:18
  • I tried many of them and none work. – Ronnel Martinez Jul 17 '20 at 09:30
  • You can run shell command via php and use mysql -e option in CLI for execute deisred function or procedure – Enrique René Jul 17 '20 at 09:31
  • 2
    *"I tried many of them and none work. "* then post your attempts and explain why they didn't work and/or the error you received. – Thom A Jul 17 '20 at 09:39
  • @Larnu I did some experiment and I guess the string to hex conversion login on the given link works but I'll have to add 0x as prevalue and the output should be exactly 28 characters so I'll have to add 0 as postvalue until it reaches the 28 characters. Thank you. – Ronnel Martinez Jul 17 '20 at 09:45
  • Like the output is `696E6A656C30323130` and I'll have to add `0x` as prevalue and `00000000` as postvalue for it to match the 28 characters. so basically the final output would be `0x696E6A656C3032313000000000` – Ronnel Martinez Jul 17 '20 at 09:46
  • @larnu you can add an answer and I'll approve it. Thanks for the help. – Ronnel Martinez Jul 17 '20 at 09:53
  • If the above answered your question, I'll flag as a duplicate, as there's no benefit to me answering the qusetion when it's already answered. INstead upvote the answer (and question) of the duplicate. :) – Thom A Jul 17 '20 at 09:55

0 Answers0