收到意外的T_CONSTANT_ENCAPSED_STRING,创建目录

时间:2012-09-25 19:25:55

标签: php

我尝试创建文件夹目录名“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);
}

2 个答案:

答案 0 :(得分:0)

"\n"的上一次连接错过了.之前的{{1}}。该错误基本上意味着您有一个不期望的字符串。

答案 1 :(得分:0)

将您的代码更改为:

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

此外,您可能希望将\n换成常量PHP_EOL