I have to echo a string that could contain everything into the following html line:
<a href="javascript:void()" onclick="function(<?php ... ?>)">...</a>
I don't know how to properly escape the string I pass with php, there seem to be many problems and json_encode is not working as it wraps the output in double quotes which is not working as the double quotes already begin after "onclick=".
Just replacing single quotes also doesn't work as "\'" would be replaced to "\'".
Any ideas?