jsonp.php 383 B

1234567891011121314
  1. <?php
  2. error_reporting(0);
  3. $callback = $_REQUEST['callback'];
  4. if ( ! $callback ) {
  5. $callback = explode("?",end(explode("/",$_SERVER['REQUEST_URI'])));
  6. $callback = $callback[0];
  7. }
  8. $json = $_REQUEST['json'];
  9. if($json) {
  10. echo $callback . '([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])';
  11. } else {
  12. echo $callback . '({ "data": {"lang": "en", "length": 25} })';
  13. }
  14. ?>