要使用PHP读取文件内容,可以使用file_get_contents()函数或fopen()和fread()函数的组合。
使用file_get_contents()函数:
$fileContent = file_get_contents('file.txt');echo $fileContent;这将会读取file.txt文件的内容,并将其输出到浏览器上。
使用fopen()和fread()函数:
$handle = fopen('file.txt', 'r');if ($handle) { $fileContent = fread($handle, filesize('file.txt')); fclose($handle); echo $fileContent;}这将会打开file.txt文件,读取其内容,并将其输出到浏览器上。然后,关闭文件句柄。
注意:以上代码中的file.txt是文件的路径,你需要根据实际情况进行替换。

