改变在PHP文件中的行 [英] change line in php file

查看:163
本文介绍了改变在PHP文件中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  {
$ data ='anydata';

$ age ='33';

$ site ='mysite';

















$ b $ p> 问题:我怎样才能改变字符串与PHP?

解决方案

行,从手册页这里



fwrite,从手册页此处



取消链接,从手册页此处

重命名,从手册页此处 a>



chmod,从手册页这里

  1。打开file1(在文件中),file2(outfile)
2.使用fgets从file1
读取单行(下一行)3.需要修改该字符串?这样做。
4.使用fwrite将字符串写入file2(只是该行)
5.当不是file1的结尾文件(eof)时,循环回到2
6.关闭file1和file2
7.取消链接(删除)file1
8.将file2重命名为file1名称
9.相应的chmod


for example I have this php file:

{
$data= 'anydata';

$age = '33';

$site ='mysite';

$name = 'anyname'

}

Question: How I can change the strings with php ?

解决方案

fgets, read a single line, from the Manual page here

fwrite, from Manual page here

unlink, from Manual page here

rename, from Manual page here

chmod, from Manual page here

1. Open file1 (in file), file2 (outfile)
2. use fgets reading single lines (the next line) from file1
3. need to modify that string? do so.
4. use fwrite to write string to file2 (just that line)
5. loop back to 2 when not end-of-file (eof) of file1
6. close file1 and file2
7. unlink (delete) file1
8. rename file2 to file1 name
9. chmod accordingly

这篇关于改变在PHP文件中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆