bushdiver bushdiver - 2 months ago 8
HTML Question

How to ignore question mark ? characters when printing html with PHP

I'm printing obfuscated html code with PHP that has a LOT of question marks in it.
The problem is this is causing PHP parse errors:

Parse error: syntax error, unexpected '?'

How would I go about escaping/ignoring them without actually escaping them in the html code?

Ex:

<?php if ($print_html) { ?>

var test = "a;sdkfhals?asdf/?aHluh?/daldj????adfakjsd????????????/asdfj?";

<?php } ?>


Edit:
https://jsfiddle.net/0j1fm7p4/1/

changing short_open_tag to Off in my php.ini fixed the problem

Answer

In your current example, this is because short_open_tag is On in the php.ini config file. Since you have some <? in your obfuscated var, you get this error.

Try set it to Off