搜索和替換文件或目錄的一個好類–很實用

這是個非常有用的程序,可以對文本文件進行特定的搜索,並以特定的文字替換指定的文字,舉個例子說如果我這篇文章裡有一個字全部打錯瞭,有幾十處,要一一找出來修改是件很麻煩的事,用下面這個就可以輕松搞定。–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;

發佈留言