2012-09-25 68 views
-1

我試圖創建文件夾目錄名稱「代碼」,並且我想將它保存到「status.txt」。收到意外T_CONSTANT_ENCAPSED_STRING,創建目錄

這是我的代碼問題,收到意想不到的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); 
} 
+0

您在fwrite調用的最後一個'\ n'之前缺少'.'。 – andrewsi

回答

0

你的代碼更改爲:

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

此外,您可能要交換\n出於對不斷PHP_EOL

+0

謝謝,這個小小的錯誤很煩人,再次感謝你。 –

0

你的最後串聯,爲"\n",是失蹤前的.。錯誤基本上意味着你有一個字符串,它不是預期的。

+0

謝謝,謝謝,這個小錯誤很煩人。 –

相關問題