user2327201
user2327201

Reputation: 409

PHP 5.3.13 Unexpected token < with json_encode

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.

Upvotes: 0

Views: 558

Answers (1)

Hackerman
Hackerman

Reputation: 12295

Try with this:

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

Upvotes: 1

Related Questions