-1

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

bushdiver
  • 751
  • 3
  • 12
  • 21
  • 1
    I cannot see a problem with that code. Are you _really_ sure you got the right line where the syntax error is pointed out? – arkascha Sep 25 '16 at 21:20
  • sounds like an encoding issue to me –  Sep 25 '16 at 21:22
  • @arkascha yes, I'm positive of the right line, but the actual line is much longer than the one in the example. actual line: https://jsfiddle.net/0j1fm7p4/ – bushdiver Sep 25 '16 at 21:24
  • Ah, that is something _completely_ different! Most likely you terminate the string `"` somehow, then certainly stränge things may happen. One question: why on earth is obfuscation used? That _always_ causes endless trouble, typically without real benefit... – arkascha Sep 25 '16 at 21:26
  • @arkascha exact code: https://jsfiddle.net/0j1fm7p4/1/ – bushdiver Sep 25 '16 at 21:26
  • @arkascha I agree about the obfuscation.. but company policy – bushdiver Sep 25 '16 at 21:27
  • Even worse. You work for a company that insists on using obfuscation? Oh dear... – arkascha Sep 25 '16 at 21:28

1 Answers1

1

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

Proger_Cbsk
  • 362
  • 3
  • 12