php - Find a url in content a site by url it? -



php - Find a url in content a site by url it? -

i want search content site url site, if existence url (for example: http://www.mydomain.com/) homecoming true else false.

if existence url next list, homecoming false:

- http://www.mydomain.com/blog?12 - www.mydomain.com/news/maste.php - http://www.mydomain.com/mkds/skas/aksa.html - www.mydomain.com/ - www.mydomain.com

i want accsept(find) as(only):

http://www.mydomain.com/ or http://www.mydomain.com

i tried as:

$url = 'http://www.usersite.com'; $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_returntransfer, 1); $contents = curl_exec($ch); curl_close($ch); $link="/http:\/\/mydomain.com/"; if(preg_match("/". preg_quote($link,"/"). "/m", $contents) && strstr($contents,"http://www.mydomain.com")){ echo 'true'; } else{ echo 'false'; }

but doesn't worked, want. how can prepare it?

you should not using preg_quote on link in regex form. seek using entire regex /http:\/\/mydomain.com/m instead.

$link="/http:\/\/mydomain.com/m"; if(preg_match($link, $contents) && false!== stripos($contents,"http://www.mydomain.com")){ echo 'true'; } else{ echo 'false'; }

i've updated strstr stripos , have absolute comparing it's not boolean safe function.

php curl

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -