Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mahesh V. More  >  HTML Count  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: HTML Count
Count the occurrences of a given HTML tag
Author: By
Last change: php tag
Date: 8 years ago
Size: 1,019 bytes
 

Contents

Class file image Download
/**********************************************************************

# mahesh v more
# maheshmore79@yahoo.com
# mahesh.more@solversa.com
#
***********************************************************************/
<?php
# parser class
include_once('html_count_class.php');

#html file to parse
#either local file
$file "test.html"

#or remote file
//$file = "http://www.geocities.com/maheshmore79/home.html";
//$file = "http://www.phpclasses.org";

echo "Counting for HTML page ".
    
"<font color=blue>".$file."</font>";
#pattern for matching

#for mathcing img tag
//$pattern = '/<(img|input)\s+[^>]*src\s*=\s*(?:"([^"]+)"|\'([^\']+)\'|([^\s>]+))/is';

#for mathcing a tag
$pattern '/<(a|input)\s+[^>]*href\s*=\s*(?:"([^"]+)"|\'([^\']+)\'|([^\s>]+))/is';

# new object of class ( filename & pattern )
$html = new html_count($file,$pattern);

# print out the result
echo "<br>";
echo 
"Count result is : " ;
echo 
"<font color=red>";
echo 
$html->count;
echo 
"</font>";

?>