please read before
Not duplicate with ask about server send json and client receiver for process [php] not work when server have condition e.g if else?
It's ok when i use this code.
send.php
{"text": "aaa","number": "111"}
receive.php
<?PHP
$url = "http://www.peveea.com/send.php";
$json = @file_get_contents($url, true);
$decode = json_decode($json, true);
$number = $decode[number];
echo $decode[number];
?>
but when i change send.php to this code (add tag haed) in receive.php not echo $decode[number];
<head>
<title>something</title>
<?head>
{"text": "aaa","number": "111"}
JSON is not HTML.
You cannot have a <head>
element in a JSON file.
It makes the JSON invalid, so it cannot be parsed.
your file send.php
contain html so it is not a json file
so when you use $json = @file_get_contents($url, true);
$jsnon
get the html code so it cant be parsed using json_decode()
if you print $json
you can understand that.