PHP-无法在Ubuntu中使用fopen和fwrite打开和写入文件

PHP-无法在Ubuntu中使用fopen和fwrite打开和写入文件,php,fwrite,Php,Fwrite,我正在使用Ubuntu16.04,我正在尝试将以下代码写入一个文件 <?php $path = getcwd(); $fp = fopen($path . 'data.txt', 'w') or die("Can not open the file"); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); 不包含最后的斜杠。所以你必须加上: $fp = fopen($path . '/data.txt', 'w') or die("Can

我正在使用Ubuntu16.04,我正在尝试将以下代码写入一个文件

<?php

$path = getcwd();
$fp = fopen($path . 'data.txt', 'w') or die("Can not open the file");
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);
不包含最后的斜杠。所以你必须加上:

$fp = fopen($path . '/data.txt', 'w') or die("Can not open the file");

哦,是的,斯莱什失踪了。非常感谢您的关注。它现在正在工作。干杯