It think your code won't work. For a number of reasons:
-
In your first line, you create a string, that contains single-quotes. So basically, $url
contains something like 'http://url.here'
. If you pass this to file_get_contents
you get an error:
$url = "'http://www.google.com'";
echo file_get_contents($url);
Warning: file_get_contents('http://www.google.com/'): failed to open stream:
No such file or directory in ...
You said want to check whether $url
contains a certain string. But you are checking whether the document the URL is pointing to, contains this string.
3. Maybe you mean $_GET
instead of $get
to retrieve the parameter url
that is contained in the URL?
Ok, I read from the comments that you indeed want to search for the string in the content. Still, the first line of code is wrong, so it is probably:
$needle = "http://yahoo.com/";
$contents = file_get_contents($get['url']);
if(stripos($contents, $needle) !== false) {
$qqq = "YH";
}
(<?= $qqq ?>
should work as it is).