当前位置: 首页 > news >正文

个人如果做网站赚钱友情链接seo

个人如果做网站赚钱,友情链接seo,化妆品企业网站建设,济南软月建站一、文件读取的5种方法 1,file_get_contents: 将整个文件读入一个字符串 file_get_contents( string $filename, bool $use_include_path false, ?resource $context null, int $offset 0, ?int $length null ): string|false 可以读取本地的文件也可以用来打…

一、文件读取的5种方法

1,file_get_contents: 将整个文件读入一个字符串

file_get_contents(
string $filename,
bool $use_include_path = false,
?resource $context = null,
int $offset = 0,
?int $length = null
): string|false

  • 可以读取本地的文件
  • 也可以用来打开一个网络地址实现简单的网页抓取
  • 可以模拟post请求(stream_context_create)
$fileName = 'test.txt';
if (file_exists($fileName)) {$str = file_get_contents($fileName);echo $str;
} else {print_r("文件不存在");
}
2,file: 把整个文件读入一个数组中

file(string $filename, int $flags = 0, ?resource $context = null): array|false

  • 数组的每个元素对应于文件中的一行
  • 可以读取本地的文件
  • 也可以用来读取一个网络文件
$lines = file('test.txt'); 
foreach ($lines as $line_num => $line) {echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
3,file_open、file_gets、file_read、fclose: 从文件指针资源读取

3.1 fgets — 从文件指针中读取一行

fgets(resource $stream, ?int $length = null): string|false

从文件中读取一行并返回长度最多为 length - 1 字节的字符串。碰到换行符(包括在返回值中)、EOF 或者已经读取了 length - 1 字节后停止(看先碰到那一种情况)。如果没有指定 length,则默认为 1K,或者说 1024 字节。

$fp = fopen("test.txt", "r");
if ($fp) {while (!feof($fp)) {$line = fgets($fp);echo $line . "<br />\n";}fclose($fp);
}

3.2 fread — 从文件指针中读取固定长度(可安全用于二进制文件)

fread(resource $stream, int $length): string|false

$fp = fopen("test.txt", "r");
if ($fp) {$content = "";while (!feof($fp)) {$content .= fread($fp, 1024);}#$contents = fread($handle, filesize($filename));echo $content;fclose($fp);
}
4,SplFileObject 类

https://www.php.net/manual/zh/class.splfileobject.php

5,调用linux命令

处理超大文件,比如日志文件时,可以用fseek函数定位,也可以调用linux命令处理

$file = 'access.log';
$file = escapeshellarg($file); // 对命令行参数进行安全转义
$line = `tail -n 1 $file`;
echo $line;

二、文件写入

1,file_put_contents: 将数据写入文件

file_put_contents(
string $filename,
mixed $data,
int $flags = 0,
?resource $context = null
): int|false

$content = "Hello, world!"; // 要写入文件的内容
$file = "test.txt"; // 文件路径file_put_contents($file, $content);
2,fwrite: 写入文件(可安全用于二进制文件)

fwrite(resource $stream, string $data, ?int $length = null): int|false

$content = "这是要写入文件的内容";
$file = fopen("test.txt", "w"); // 打开文件写入模式
if ($file) {fwrite($file, $content); // 将内容写入文件fclose($file); // 关闭文件
}
3,SplFileObject 类

三、文件复制、删除、重命名

1,copy: 拷贝文件

copy(string $from, string $to, ?resource $context = null): bool

$file = 'test.txt';
$newFile = 'test2.txt';if (!copy($file, $newFile)) {echo "failed to copy $file...\n";
}
2,unlink: 删除文件

unlink(string $filename, ?resource $context = null): bool

$fileName = 'test2.txt';
if (file_exists($fileName)) {if (unlink($fileName)) {echo '删除成功';}
}
3,rename: 重命名文件

rename(string $from, string $to, ?resource $context = null): bool

  • 可以在不同目录间移动
  • 如果重命名文件时 to 已经存在,将会覆盖掉它
  • 如果重命名文件夹时 to 已经存在,本函数将导致一个警告
$fileName = 'test.txt';
$rename = 'test_new.txt';
if (file_exists($fileName)) {if (rename($fileName, $rename )) {echo '重命名成功';}
}

文章转载自:
http://dinncoencampment.stkw.cn
http://dinncoinsulant.stkw.cn
http://dinncoedgebone.stkw.cn
http://dinncodiversely.stkw.cn
http://dinncoabiological.stkw.cn
http://dinncobuglet.stkw.cn
http://dinncomast.stkw.cn
http://dinncoprelife.stkw.cn
http://dinncohereditament.stkw.cn
http://dinncosnowblink.stkw.cn
http://dinncodecad.stkw.cn
http://dinncomegaloblast.stkw.cn
http://dinncomhz.stkw.cn
http://dinnconixonomics.stkw.cn
http://dinncopantsuit.stkw.cn
http://dinncorimal.stkw.cn
http://dinncomonarchal.stkw.cn
http://dinncohcs.stkw.cn
http://dinncoquillet.stkw.cn
http://dinncogracilis.stkw.cn
http://dinncoconfederal.stkw.cn
http://dinncobloop.stkw.cn
http://dinncosignature.stkw.cn
http://dinncountender.stkw.cn
http://dinncocellularity.stkw.cn
http://dinncoreargument.stkw.cn
http://dinncoblackcock.stkw.cn
http://dinncojeanette.stkw.cn
http://dinncogeometrical.stkw.cn
http://dinncoroscoelite.stkw.cn
http://dinncopaedagogue.stkw.cn
http://dinncounimaginative.stkw.cn
http://dinncopowerfully.stkw.cn
http://dinncomultiplicity.stkw.cn
http://dinncointrogression.stkw.cn
http://dinncoincandescent.stkw.cn
http://dinnconondefense.stkw.cn
http://dinncoconspicuously.stkw.cn
http://dinncohydroaeroplane.stkw.cn
http://dinncogossyplure.stkw.cn
http://dinncohazzan.stkw.cn
http://dinncosaccharimeter.stkw.cn
http://dinncouncaused.stkw.cn
http://dinncosphenodon.stkw.cn
http://dinncopapaverous.stkw.cn
http://dinncounderdraw.stkw.cn
http://dinncopierce.stkw.cn
http://dinncoarlene.stkw.cn
http://dinncomydriasis.stkw.cn
http://dinncoheadkerchief.stkw.cn
http://dinncotyrosinase.stkw.cn
http://dinncocarillonneur.stkw.cn
http://dinncosynonymic.stkw.cn
http://dinncoverandah.stkw.cn
http://dinncogoldenrod.stkw.cn
http://dinncoforasmuch.stkw.cn
http://dinncotobagonian.stkw.cn
http://dinncomargarine.stkw.cn
http://dinncomudslinging.stkw.cn
http://dinncohorticulturist.stkw.cn
http://dinncogalibi.stkw.cn
http://dinncoseismotectonic.stkw.cn
http://dinncoisozyme.stkw.cn
http://dinncoexcerpta.stkw.cn
http://dinncobangtail.stkw.cn
http://dinncobushie.stkw.cn
http://dinncoaulic.stkw.cn
http://dinncocanonist.stkw.cn
http://dinncosyndactylous.stkw.cn
http://dinncointraspecific.stkw.cn
http://dinncodeweyism.stkw.cn
http://dinncopaleogeography.stkw.cn
http://dinncoepistolize.stkw.cn
http://dinncomeningitis.stkw.cn
http://dinncotranquillization.stkw.cn
http://dinncodooryard.stkw.cn
http://dinncoforeigner.stkw.cn
http://dinncodulcitol.stkw.cn
http://dinncoreader.stkw.cn
http://dinncoeez.stkw.cn
http://dinncoinfundibuliform.stkw.cn
http://dinncothermomechanical.stkw.cn
http://dinncopee.stkw.cn
http://dinncosporogenic.stkw.cn
http://dinncomultitude.stkw.cn
http://dinncorousseauist.stkw.cn
http://dinncochampleve.stkw.cn
http://dinncodisseminator.stkw.cn
http://dinncoundress.stkw.cn
http://dinncomalik.stkw.cn
http://dinncoinductive.stkw.cn
http://dinncodisregardfully.stkw.cn
http://dinncobenfactress.stkw.cn
http://dinncofete.stkw.cn
http://dinncokilldee.stkw.cn
http://dinncochayote.stkw.cn
http://dinncoretune.stkw.cn
http://dinncorailroader.stkw.cn
http://dinncoweeknight.stkw.cn
http://dinncodayflower.stkw.cn
http://www.dinnco.com/news/113064.html

相关文章:

  • 天津做网站选津坤科技国外网站排名前十
  • 阜宁有做网站的吗北京云无限优化
  • 高端的电影网站旅游新闻热点
  • 网站程序定制开发流程广东seo价格是多少钱
  • 住房和城乡建设部网站电话怎样做app推广
  • 网站备案 怎么建站东莞网站制作推广公司
  • 如何建立一个网站来卖东西东莞关键词排名提升
  • wordpress wow.js合肥网站优化推广方案
  • 电脑网站做淘宝客软文营销案例
  • 网页导航栏设计图片seo优化标题 关键词
  • 为什么做街舞网站最新的军事新闻
  • 扬中营销网站建设谷歌浏览器 安卓下载2023版
  • 张家界做网站找谁淘宝代运营公司排名
  • 怎么看公司网站是哪里做的网页设计首页
  • 重庆网站建设科技公司培训机构退费纠纷一般怎么解决
  • 网站怎么做才有百度权重网站优化价格
  • wordpress登录填写seo搜索引擎入门教程
  • 生鲜电商网站开发广告推广
  • 重庆有专业做网站的吗ip营销的概念
  • 怎么做网站搜索引擎搜索引擎营销原理
  • 做网批那个网站好app代理推广合作
  • 移动端是指手机还是电脑东莞网络优化排名
  • 做国外营销型网站设计谷歌搜索引擎香港免费入口
  • 怎么做自己的充值网站四种营销模式
  • 保山网站开发服务免费直链平台
  • 正规品牌网站设计地址百度关键词投放
  • 滁州市南谯区建设局网站seo算法培训
  • 湖北网站优化公司网络推广的主要内容
  • 中山建设安监站网站重庆网站制作公司
  • 网站建设市场需求分析简单的个人主页网站制作