Finding HTML with PHP
Posted: Sun Mar 05, 2006 6:14 pm
I need to use PHP to find "<!--stuff-->" and let me know if it finds it. Otherwise I don't want the script to do anything. This script is a guess...but it gives me false positives; that means if the comment is not in the file (as is the case with my example below) it still says it found the comment.
Sorry to post this twice but the first thread pretty much became ignored because while people had good intentions it K-Oed the topic and I never got anywhere close to an answer! Please don't post if you have no clue how to approach this; thanks!
John
Code: Select all
<html><head></head><body>
<?php
$fh = fopen('test.php', "rb");
$file = fread($fh, filesize('test.php'));
fclose($fh);
if(strpos($file, "<!--stuff-->")!== false)
{echo "string found";}
else
{echo "string not found";}
?></body></html>John