My file located in my localhost is called datos_pc.php
, it is the one that contains the name of the PC and the MAC, which I need to keep record of activities by computer, for this I have the file with the data in a% % co:
<?php
header('Access-Control-Allow-Origin: *');
$array = array(
'pc_name' => 'DESKTOP-RS4KBQP',
'pc_mac' => 'D4-85-64-16-20-06'
);
echo json_encode($array);
?>
And to access from the server to this file that is in each computer I use this function:
$file = 'http://127.0.0.1/unicos/datos_pc.php';
$file_headers = @get_headers($file);
if(!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
echo ' nooooo existe ';
}
else {
$data = file_get_contents($file);
$data = json_decode($data, true);
echo $data['pc_name'];
}
But does it always return a Array
message, did someone do something similar? thank you very much !!!