搜索和替换文件或目录的一个好类--很实用

2016-01-29 14:27 7 1 收藏

搜索和替换文件或目录的一个好类--很实用,搜索和替换文件或目录的一个好类--很实用

【 tulaoshi.com - PHP 】

  这是个非常有用的程序,可以对文本文件进行特定的搜索,并以特定的文字替换指定的文字,举个例子说如果我这篇文章里有一个字全部打错了,有几十处,要一一找出来修改是件很麻烦的事,用下面这个就可以轻松搞定。--teaman.oso.com.cn
类文件 search_replace.inc
<?php


        class search_replace{

                var $find;
                var $replace;
                var $files;
                var $directories;
                var $include_subdir;
                var $ignore_lines;
                var $ignore_sep;
                var $occurences;
                var $search_function;
                var $last_error;

        //以下进行函数定义和设置
         
                function search_replace($find, $replace, $files, $directories = '', $include_subdir = 1, $ignore_lines = array()){

                        $this-find            = $find;
                        $this-replace         = $replace;
                        $this-files           = $files;
                        $this-directories     = $directories;
                        $this-include_subdir  = $include_subdir;
                        $this-ignore_lines    = $ignore_lines;

                        $this-occurences      = 0;
                        $this-search_function = 'search';
                        $this-last_error      = '';

                }

        /***************************************
        ** Accesso

来源:https://www.tulaoshi.com/n/20160129/1493347.html

延伸阅读
  Ehlib3.0版本以上虽然支持排序功能,但不支持带有Order By的SQL语句,而且排序很慢;我写的这个排序函数,利用ADO的sort方法,排序很快,几万条数据也是很快。该函数支持Lookup字段排序,不支持计算字段排序,因为计算字段值在内存里高速运算。排序分为:升序、降序和默认三种,支持排序图标。 procedure   SortDBG...
标签: PHP
  <?php   exec("/bin/grep -r '$oldword' $rootpath", $results, $errorCode);   if ($errorCode){   if ($errorCode == 1){   echo "Possibly no files were found with $oldword in them<BR\n";   }   echo "OS Error: $errorCode<BR\...
标签: Web开发
一个目录遍历函数?php function dirtree($path="./test") {   echo "dl";   $d = dir($path);   while(false !== ($v = $d-read())) {     if($v == "." $v == "..")       continue;     $file = $d-path."/".$v;     echo "dt$v";     if(i...
标签: ASP
         最近迷恋上作网站了,使用asp开发,发现asp有好多的漏洞,而且在一个网站中有好多的代码是重复使用的,所以就查询了一些资料发现在asp中可以使用类的思想,所以就写了这个类,写的不好,但是比较实用。      <meta http-equiv="Content-Type" content="text/ht...
标签: ASP
       '******************************    '名称: ChkInvStr    '参数:Str    '返回值:True/False    '创建时间:2005年5月2日    '作用:检查参数是否有非法字符    '******************************    Public Function ChkInvS...

经验教程

215

收藏

97
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部