File
[ class tree: File ] [ index: File ] [ all elements ]

Class: File_SearchReplace

Source Location: /File_SearchReplace-1.1.2/SearchReplace.php

Class Overview


Search and Replace Utility


Author(s):

Version:

  • 1.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 48]
Search and Replace Utility


[ Top ]


Class Variables

$directories =

[line 56]


Type:   mixed


[ Top ]

$files =

[line 55]


Type:   mixed


[ Top ]

$find =

[line 53]


Type:   mixed


[ Top ]

$ignore_lines =

[line 58]


Type:   mixed


[ Top ]

$ignore_sep =

[line 59]


Type:   mixed


[ Top ]

$include_subdir =

[line 57]


Type:   mixed


[ Top ]

$last_error =

[line 63]


Type:   mixed


[ Top ]

$occurences =

[line 60]


Type:   mixed


[ Top ]

$php5 =

[line 62]


Type:   mixed


[ Top ]

$replace =

[line 54]


Type:   mixed


[ Top ]

$search_function =

[line 61]


Type:   mixed


[ Top ]



Method Detail

File_SearchReplace (Constructor)   [line 80]

File_SearchReplace File_SearchReplace( string $find, string $replace, array $files, [array $directories = ''], [bool $include_subdir = TRUE], [array $ignore_lines = array()])

Sets up the object
  • Access: public

Parameters:

string   $find   —  The string/regex to find.
string   $replace   —  The string/regex to replace $find with.
array   $files   —  The file(s) to perform this operation on.
array   $directories   —  (optional) The directories to perform this operation on.
bool   $include_subdir   —  If performing on directories, whether to traverse subdirectories.
array   $ignore_lines   —  Ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.

[ Top ]

doReplace   [line 535]

void doReplace( )

This starts the search/replace off. Call this to do the replace.

First do whatever files are specified, and/or if directories are specified, do those too.

  • Access: public

[ Top ]

doSearch   [line 520]

void doSearch( )

This starts the search/replace off. The behavior of this function will likely to be changed in future versions to work in read only mode. If you want to do actual replace with writing files - use doReplace method instead.
  • Access: public

[ Top ]

getLastError   [line 120]

string getLastError( )

Accessor for retrieving last error.
  • Return: The last error that occurred, if any.
  • Access: public

[ Top ]

getNumOccurences   [line 106]

int getNumOccurences( )

Accessor to return the number of occurences found.
  • Return: Number of occurences found.
  • Access: public

[ Top ]

setDirectories   [line 176]

void setDirectories( array $directories)

Accessor for setting directories variable.
  • Access: public

Parameters:

array   $directories   —  The directories to perform this operation on.

[ Top ]

setFiles   [line 162]

void setFiles( array $files)

Accessor for setting files variable.
  • Access: public

Parameters:

array   $files   —  The file(s) to perform this operation on.

[ Top ]

setFind   [line 134]

void setFind( string $find)

Accessor for setting find variable.
  • Access: public

Parameters:

string   $find   —  The string/regex to find.

[ Top ]

setIgnoreLines   [line 205]

void setIgnoreLines( array $ignore_lines)

Accessor for setting ignore_lines variable.
  • Access: public

Parameters:

array   $ignore_lines   —  Ignore lines beginning with any of the strings in this array. This feature only works with the "normal" search.

[ Top ]

setIncludeSubdir   [line 190]

void setIncludeSubdir( bool $include_subdir)

Accessor for setting include_subdir variable.
  • Access: public

Parameters:

bool   $include_subdir   —  Whether to traverse subdirectories or not.

[ Top ]

setReplace   [line 148]

void setReplace( string $replace)

Accessor for setting replace variable.
  • Access: public

Parameters:

string   $replace   —  The string/regex to replace the find string/regex with.

[ Top ]

setSearchFunction   [line 223]

void setSearchFunction( string $search_function)

Function to determine which search function is used.
  • Access: public

Parameters:

string   $search_function   —  The search function that should be used. Can be any one of: normal - Default search. Goes line by line. Ignore lines feature only works with this type. quick - Uses str_replace for straight replacement throughout file. Quickest of the lot. preg - Uses preg_replace(), so any regex valid with this function is valid here. ereg - Uses ereg_replace(), so any regex valid with this function is valid here.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:58:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.