广告赞助

php教程

PHP写入TXT文本方法

我的站长站 2021-09-21 人阅读
<?
$url = $_GET['url'];
$file = "url.txt";
$handle =fopen($file,'a'); 
fwrite($handle,""); 
fwrite($handle,"URL:");
fwrite($handle,"$url"); 
fclose($handele);
header("location: $url");
?>

本教程只分享生成txt文件的方法,生成的内容自行增加修改。

保存到PHP文件,然后访问就会生成一个txt的文件,里面记录了所有被访问过的外链链接。

相关推荐
  • PHP读取TXT
  • PHP读取TXT文本内容方法大全

    fread函数方法<?php$file_path = "test.txt";if(file_exists($file_path)){$fp = fopen($file_path,"r");$str = fread($fp,filesize($file_path));//指定读取大小,这里把整个文件内容读取出来echo $str = str_replace("\r\n","<br />",$str);fcl...

    php教程 14 4周前
  • file_get_contents读取TXT指定数据方法

    file_get_contents()读取整个文件方法如果文件不是特别大,你可以简单地使用file_get_contents()读取整个文件内容,然后使用字符串函数(如substr(), strpos(), strstr(), explode()等)来提取或处理特定数据。$content = file_get_contents(&#39;path/to/y...

    php教程 13 1个月前
  • PHP两个TXT文件对比,去除重复内容

    示例代码<?php// 读取两个文件的内容$file1Content = file(&#39;file1.txt&#39;, FILE_IGNORE_NEW_LINES); // 忽略行尾换行符,返回数组$file2Content = file(&#39;file2.txt&#39;, FILE_IGNORE_NEW_LINES); // 忽略行尾换行符,返回数组// 将第二个文...

    php教程 16 1个月前
最新更新