Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP获取URL的内容,并在其中搜索以回显结果_Php_Url_Search_Echo_File Get Contents - Fatal编程技术网

PHP获取URL的内容,并在其中搜索以回显结果

PHP获取URL的内容,并在其中搜索以回显结果,php,url,search,echo,file-get-contents,Php,Url,Search,Echo,File Get Contents,使用php,我试图创建一个脚本,该脚本将获取url的所有内容,然后在其中搜索字符串,如果找到匹配项,则返回 假设我有一个url(),在这个url中存储了一个字符串,它也是“”。我想获取的内容并检查其源代码中是否存在“”。请尝试此代码 <?php $homepage = file_get_contents('http://www.mydomain.com/'); if (strpos($homepage,'http://www.mydomain.com/') !== false) {

使用php,我试图创建一个脚本,该脚本将获取url的所有内容,然后在其中搜索字符串,如果找到匹配项,则返回

假设我有一个url(),在这个url中存储了一个字符串,它也是“”。我想获取的内容并检查其源代码中是否存在“”。请尝试此代码

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

一起使用
curl
DOMDocument
有时候你只需要从头开始思考,谢谢!工作!
$content = file_get_contents('http://someurl.com');
$pos = strpos($content, 'Some String');
if($pos!==false){
echo 'String Exists';
}