I am curious is that any build in or easier way to encode string to \xHH format in PHP? I am trying to implement rule 3 and rule 4 from XSS OWASP Prevention with build in function or easier approach. but, I can't find any in the internet.
as far as I found, I need to make manual encoder/decoder for 'string to \xHH' format in PHP.
expected code in php
print(StringToXHH("foo"));
// output --> \x66\x6f\x6f
any idea?