문제

Using php, I'm trying to create a script which will grab all the contents of a url then search within it for a string and echo if the match was found.

Say I have a url (http://www.mydomain.com) and within this url, there is a string stored in it which is also 'http://www.mydomain.com'. I want to grab the contents of http://www.mydomain.com and check if 'http://www.mydomain.com' is present in its source code or not.

도움이 되었습니까?

해결책

try this code

<?php
$homepage = file_get_contents('http://www.mydomain.com/');
if (strpos($homepage,'http://www.mydomain.com/') !== false) {
    echo 'true';
}

enjoy :)

다른 팁

$content = file_get_contents('http://someurl.com');
$pos = strpos($content, 'Some String');
if($pos!==false){
echo 'String Exists';
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top