Reputation: 1813
I am trying to output some json code and encode it... i am getting a some weird results..
Here is my php code and the header, so when I read with my application it will see it as json content type not html
header('Content-Type: application/json');
echo "{\"data\":".json_encode($showArray) . "}";
the output is this:
{"data":[{"id":"4628","name":"NCIS","season":"11"},{"id":"21934","name":"NCIS: Los Angeles","season":"5"},{"id":"24591","name":"The Real NCIS","season":"1"},{"id":"34498","name":"NCIS: Red","season":"1"},{"id":"38017","name":"NCIS: New Orleans","season":"1"},{"id":"3039","name":"Charmed","season":"8"},{"id":"6125","name":"The Real World","season":"28"},{"id":"32724","name":"Da Vinci's Demons","season":"2"},{"id":"27924","name":"The Franchise","season":"2"},{"id":"6218","name":"The Streets of San Francisco","season":"5"},{"id":"3253","name":"Da Vinci's Inquest","season":"7"},{"id":"6862","name":"Da Vinci's City Hall","season":"1"},{"id":"32034","name":"Oddities: San Francisco","season":"2"},{"id":"14884","name":"San Francisco International Airport","season":"1"},{"id":"2616","name":"Animal Cops: San Francisco","season":"1"},{"id":"5208","name":"Sir Francis Drake","season":"1"},{"id":"29590","name":"Easy Chinese","season":"2"},{"id":"5583","name":"The Arlene Francis Show","season":"1"},{"id":"26665","name":"Jancis Robinson's Wine Course","season":"1"},{"id":"17968","name":"Foul Play","season":"1"}]}
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
if i don't do the header i don't have the hostin24 anlaystic code
anyone know why the Hosting24 Anlystics Code is showing? is this the server adding it?
if so.. does anyone recommend a free php server?
thanks...
Upvotes: 2
Views: 212
Reputation: 717
Looks like an auto append that your host set up. You can try and put exit;
at the end of your PHP script preventing it from reaching the end where the auto append would happen.
See here for similar issue: Webhoster inserts a javascript which brokes my code how to remove it?
Edit: I should note depending on the level of access your host grants you other options (less hacky) may be available to you. Read above link.
Upvotes: 1