-1

我试图创建文件夹目录名称“code”,我想将它保存到“status.txt”。

这是我收到意外 T_CONSTANT_ENCAPSED_STRING 的代码问题。

if(is_writeable($newdir . "/status.txt")) {
    if (fwrite($statusTxt, $statusCode . "," . $status . "," . $share . "," . $date . "," . $permission "\n")){
}

这种方式创建目录并将其保存到status.txt是否正确?下面是其余的代码。

非常感谢,并感谢您的帮助。

$newdir = "../../data/code";
umask(0007);
if(!file_exists($newdir))
{
    mkdir($newdir, 02770);
$statusTxt = fopen($newdir. "/status.txt", "a");
}
if(is_writeable($newdir . "/status.txt")) {
    if (fwrite($statusTxt, $statusCode . "," . $status . "," . $share . "," . $date . "," . $permission "\n")){
}
    echo "<p>Your form has succesfully been submit!</p>";
}
fclose($statusTxt);
}
4

2 回答 2

0

您的最后一个连接,对于"\n", 缺少它.之前的。该错误基本上意味着您有一个不期望出现的字符串。

于 2012-09-25T19:28:02.460 回答
0

将您的代码更改为:

if(is_writeable($newdir . "/status.txt")) {
    if (fwrite($statusTxt, $statusCode . 
             "," . $status . "," . $share . "," . 
             $date . "," . $permission  . "\n"))
                                     ^^^^^^  
...

此外,您可能想换掉\n常量PHP_EOL

于 2012-09-25T19:30:50.463 回答