I am new in php. I want to post some data as an input to the php page from the command line of the windows. In fact, I use MATLAB via system(curl) command to post some string as the input to the php file. I want to use this string in the body of the php and write it to some file and then read that file with matlab.
Here is my code in matlab (I want to run matlab code to run php in behind and then given back to me in matlab two data (time and given string):
command = strcat('curl',{' '},'--data "name=ii"',{' '},'http://sample.com/a.php');
[~,cmdout] = system(command{1});
expression = '(http://).*(.dat)';
[~,matches] = regexp(cmdout,expression,'tokens','match');
url = matches{1};
command = strcat('curl',{' '}, url);
[~,cmdout] = system(command{1})
And here is my code in php (a.php):
<?php
parse_str($diff[1], $_GET);
print $diff;
$filename='http://sample.com/a.dat';
$t_now=time();
$list=array($t_now,$diff);
$file=fopen($filename,'w');
foreach ($list as $line)
{
fputcsv($file,explode(',',$line));
}
fclose($file);
echo "
<html>
<body>
<a href=$filename target='_self'>Ok</a>
</body>
</html>";
?>