我想显示POST
变量的内容,但是我的输出是空的。显示内容POST
<?php
$dir = '/var/www/devData/test';
// create new directory with 777 permissions if it does not exist yet
// owner will be the user/group the PHP script is run under
if (!file_exists($dir)) {
mkdir ($dir, 0777);
}
$stringData = print_r($_POST['data'], true);
$file = "/var/www/devData/test/ciao.txt";
$fh = fopen($file, 'a+') or die("can't open file");
$fla = 0;
$arr = array();
$i = 0;
while(!feof($fh)) {
$theData = fgets($fh, filesize($file));
array_push($arr,$theData);
//echo $arr[$i];
$i++;
}
echo $stringData;
fclose($fh);
?>
当我调用该函数fwrite
,可变$stringData
被存储到文件中。
这是调用PHP的文件中的函数:
$.post("JS/foo.php", {data: options_label}, function(result){alert(options_label) }, "json");
其中options_label
是一个数组。
我试着用decode_json
等等,但$stringData
仍然是空的。
你想显示什么? – Don 2012-07-31 19:15:23
变量的含义$ stringData – Edivad 2012-07-31 19:22:58
但这就是为什么我问......你是什么意思的“contenute”? – Don 2012-07-31 19:23:53