学无先后,达者为师

网站首页 PHP其他 正文

PHP读取文本文件(TXT)

更新时间: 2021-01-04 PHP其他

PHP读取txt文件

<?php
header("content-type:text/html;charset=utf-8");

$file = "demo2.txt";

if(file_exists($file)){
####使用 file_get_contents函数
$res = file_get_contents($file);
$res_new = str_replace("\r\n",",",$res); ##同上.
echo $res_new;
####数据的其他处理
}else{

echo "file not exists!";
}

?>


栏目分类
最近更新