json parse from result.php file url

i have a php file that return json. here my php file.



http://dev.mediaodd.com/data/testjson.php



if i use writing testjson.json file it will success but if i use .php it will failed.



this is my output script:



<?php
// copy file content into a string var

$jsondata = file_get_contents('http://dev.mediaodd.com/data/testjson.php');
$obj = json_decode($jsondata,true);


echo $obj['company'][0]['id'];

?>


what did i do wrong?



file_get_contents cant read .php file?



my testjson.php file return same as testjason.json file.



Answers

after clarification by OP, the following is not the case



file_get_contents cannot read from url resource unless this has been setup explicitly in php.ini configuration (not recommended mostly for security reasons).



So you should not use file_get_contents('http://dev.mediaodd.com/data/testjson.php'); to read an http resource, but instead read from local php files only that exist in the (server) disk