PHP Classes

Website PHP Full Text Search: Search for text expressions in files in a folder

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 166 All time: 8,870 This week: 191Up
Version License PHP version Categories
website-full-text-se 1.0.0Freeware7.4Files and Folders, Searching, PHP 7


This package can be used to search for text expressions in files in a folder.

It can analyze files inside a given start folder and searches for text that can be found in the files.

The class can scan for text that may be present only in specific sections of the files that may be delimited using specific marks.

The results are display in an HTML page using a template defined by the class.

Innovation Award
PHP Programming Innovation award nominee
March 2021
Number 5
Sometimes developers need to find specific information in the files that they use to develop the Web sites that they implement.

This package provides a solution for finding the information they need with support to filter the section to text that may be in the files in sections delimited by certain start and end text marks.

Manuel Lemos
Picture of Gert Massheimer
  Performance   Level  
Name: Gert Massheimer <contact>
Classes: 2 packages by
Country: United States United States
Age: 62
All time rank: 3634480 in United States United States
Week rank: 358 Up44 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x


= ' | Suchergebnisse';
$description = 'Suchergebnisse auf';
$keywords = 'Suche';
$pageTopic = 'Search Results on';

$_SERVER['DOCUMENT_ROOT'] . '/assets/php/functions.php';
$page = pathinfo(__FILE__, PATHINFO_FILENAME);
$lang = 'de';

"<!doctype html>\n";
"<html lang='$lang'>\n";
headPHP($pageTitle, $keywords, $description);
" <div class='container-fluid px-md-5'>\n";
" <a id='top-content'></a>\n";
" <div id='pageContent'>\n";
" <div class='d-flex justify-content-between'>\n";
" <h1 class='text-warning'>$pageTopic</h1>\n";
" </div>\n";
" <hr class='mb-3'>\n";

// make sure, you're calling the right class!
new MySearch();

" </div>\n";
" </div>\n";
" </body>\n";


SearchClass - Full Text Search for Websites

The SearchClass is a full text search for websites with multiple pages. It works with HTML or PHP based sources. The class can be extended with your own templates and/or your translations.


  • All variables are changeable by extending the class
  • The search can be limited to parts of the source
  • The content of a source can be completely ignored
  • You can define your DOCUMENT_ROOT
  • Additional folders can be included
  • A log file can be written to collect the search terms used
  • The file extensions considered for the search can be limited
  • Google-Style search results with text excerpts

The class is full of comments and should be self-explanatory.


![Search Result Page][image-1]


  • *SearchClass.php* is the main class
  • *MySearch.php* is an example extension of the main class
  • *template/search.html* is an HTML-template to display the search results
  • *template/search.php* is my own PHP-template to display the search results

How it works

After calling the class by using a form (which is part of the HTML-template), the class will start a search according to the given folders.

For the initial search filters will be applied:

  • Ignore all HTML tags
  • Ignore everything that is included via `<script>`
  • Ignore all PHP-code aside from your defined meta-tag variables
  • If a source contains `<!--no_search -->`, ignore it's content
  • Ignore everything that is outside of: - `<!-- no_search_start -->` - ... and ... - `<!-- no_search_stop -->`

The search limiters:

<!--no_search -->

<!-- no_search_start -->

<!-- no_search_stop -->

Will also work inside PHP-code by applying the standard PHP comment in front or around it.

E.g. //<!-- no_search --> or /<!-- no_search -- >/

All relevant file-paths will be stored in an array then the files will be searched again and a text excerpt will be extracted. Finally the search results will be displayed in Google-style result page.

There are two options to display the page title:

  1. Use the content of the title-tag from the HTML header - `<title>...</title>`
  2. Use the content of a pre-defined PHP variable inside the source file - `$this->phpTitle = '...'`

There are also two options to display the page description:

  1. Use the content of the description meta-tag from the HTML header - `<meta name="description" content="...">`
  2. Use the content of a pre-defined PHP variable inside the source file - `$this->phpDesc = '...'`

In both cases, the PHP variable will overwrite the meta-tag, if it exists, too.


If no limiter is found inside a source, *ALL* text will be searched and used for the initial search!

But for the text excerpt itself, all filters will be applied before displaying it.

At the end of the main class or its extension is the template included that displays the result page. Make sure you include the template only ones. If you don't extend the main class, include the template there. If you extend the main class, include the template in its extension.


The minimum PHP version is 7.4


  • screenshot.png
  Files folder image Files  
File Role Description
Files folder imagetemplates (2 files)
Accessible without login Plain text file LICENSE Lic. License text
Plain text file MySearch.php Class Class source
Accessible without login Plain text file Doc. Documentation
Plain text file SearchClass.php Class Class source

  Files folder image Files  /  templates  
File Role Description
  Accessible without login Plain text file search.html Data Documentation
  Accessible without login Plain text file search.php Example Example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,870
This week:191Up