Im using this ti search for specific text in a webpage:

HTML Code:
<?php
$link = "http://www.test.com/";
$linkcontents = file_get_contents($link);
	
$needle = "Hello";
if (strpos($linkcontents, $needle) == false) {
echo "String not found";
} else {
echo "String found";
}
?>
But when I try searching a .php webpage I get errors. Any ideas ?