0

I setup a local site but when I goto it I get this error Uncaught SyntaxError: Unexpected token < which brings me to this line of code:

<script type="text/javascript">
pepsiMedia.loadConfig(<?= json_encode($this->config) ?>);
$(document).ready(pepsiMedia.ready);
</script>

I am assuming it has something to do with the json_encode or my PHP version, what can I do to fix this?

I am bit hesitant about showing what $this->config is as it has sensitive information, let me know if you need it and I will try to recreate it without sensitive information.

8
  • Are you sure it's parsing the PHP in the first place? Can you check in the source code?= Commented Aug 26, 2013 at 19:58
  • What is the extension of the file ? Commented Aug 26, 2013 at 19:58
  • 3
    Did you enable short_open_tag? Before 5.4.0, the <?= ... ?> shorthand requires it, although it should be enabled by default. Commented Aug 26, 2013 at 19:59
  • Sounds more like a JS error than a PHP error. Are you sure that <?= is working on your system and the PHP code is actually being executed? Commented Aug 26, 2013 at 19:59
  • try <?php echo json_encode($this->config); ?> instead. if that doesn't work try printing $this->config maybe it's not accessible. Commented Aug 26, 2013 at 20:01

1 Answer 1

1

Try with this:

<script type="text/javascript">
pepsiMedia.loadConfig(<?php echo json_encode($this->config); ?>);
$(document).ready(pepsiMedia.ready);
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.