-1

我有这个 php 代码:

<?php
echo ("Setting up data..."); 
$today = date("YmdHi");
$wtoday = $today
$im = $_GET["im"];
$fim = "tips/$today/im.txt";
$fwtoday = "tips/$today/today.txt";
?>
<?php
$fp = fopen ($fwtoday, "w"); # w = write to the file only, create file if it does not exist, discard existing contents 
if ($fp) { 
    fwrite ($fp, $wtoday); 
    fclose ($fp); 
    echo ("Today written"); 
} 
else { 
    echo ("Today was not written"); 
}
?>
<?php
$fp = fopen ($fim, "w"); # w = write to the file only, create file if it does not exist, discard existing contents 
if ($fp) { 
    fwrite ($fp, $im); 
    fclose ($fp); 
    echo ("Im written"); 
} 
else { 
    echo ("Im was not written"); 
}
?>

最后今天和我没有写,我的错误在哪里???我认为这与文件权限无关。我忘了在帖子中写关于 $fwtoday ="tips/$today/today.txt";的内容,仍然无法正常工作。

4

3 回答 3

2
$wtoday = $today

缺少分号,解析错误。

那个asice,您似乎正在尝试打开存储在变量中的文件名$fwtoday,您似乎没有在任何地方定义该文件名。

于 2013-09-03T10:00:55.370 回答
2

将这些行插入文件的前面,并分享给定的错误:

error_reporting(E_ALL);
ini_set('display_errors','On');
于 2013-09-03T10:11:24.823 回答
0

我没有看到$fwtoday的定义。你也不需要这样做:

?>
<?php
于 2013-09-03T10:01:40.433 回答