<?php header('content-type: application/json');
$json = json_encode($data);
echo isset($_GET['callback'])
? "{$_GET['callback']}($json)"
: $json;
Or should I for example filter the $_GET['callback']
variable so that it only contains a valid JavaScript function name? If so, what are valid JavaScript function names?
Or is not filtering that variable a bit of the point with JSONP?