Users call a web service API in my PHP code but don’t properly encode the input (like the & sign etc) so because of nonsense (I can’t use the b* word here but you know that a developer don’t care about politics or feelings, you do it right or not!) it is my problem to fix it… How can I encode the input XML before I try to parse it in PHP?
I did a string replace for the & sign but off-course there are more invalid characters in the universe that these people (the a* word) can use.
Without more details and code its hard to say exactly what you need, but look at
urlencode()orhtmlentities()orhtmlspecialchars()http://php.net/manual/en/function.urlencode.php
http://www.php.net/manual/en/function.htmlentities.php
https://www.php.net/manual/en/function.htmlspecialchars.php