bushdiver bushdiver - 1 year ago 79
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?


<?php if ($print_html) { ?>

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

<?php } ?>


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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download