Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/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 - Fatal编程技术网

停止PHP脚本放入URL';地址栏里有什么?

停止PHP脚本放入URL';地址栏里有什么?,php,Php,我有一个脚本,可以从URL列表中提取元数据,但当我尝试提取太多时,它会说URL太长,无法运行 我的问题是我怎样才能阻止这种事情发生 <?php ini_set( 'default_charset', 'UTF-8' ); error_reporting(E_ALL); //ini_set( "display_errors", 0); function parseUrl($url){ //Trim whitespace of the url to ensure proper chec

我有一个脚本,可以从URL列表中提取元数据,但当我尝试提取太多时,它会说URL太长,无法运行

我的问题是我怎样才能阻止这种事情发生

<?php
ini_set( 'default_charset', 'UTF-8' );
error_reporting(E_ALL);
//ini_set( "display_errors", 0);
function parseUrl($url){
    //Trim whitespace of the url to ensure proper checking.
    $url = trim($url);
    //Check if a protocol is specified at the beginning of the url. If it's not,   prepend 'http://'.
    if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
            $url = "http://" . $url;
    }
    //Check if '/' is present at the end of the url. If not, append '/'.
    if (substr($url, -1)!=="/"){
            $url .= "/";
    }
    //Return the processed url.
    return $url;
}
//If the form was submitted
if(isset($_GET['siteurl'])){
    //Put every new line as a new entry in the array
    $urls = explode("\n",trim($_GET["siteurl"]));
    //Iterate through urls
    foreach ($urls as $url) {
            //Parse the url to add 'http://' at the beginning or '/' at the end if not   already there, to avoid errors with the get_meta_tags function
            $url = parseUrl($url);
            //Get the meta data for each url
            $tags = get_meta_tags($url);
            //Check to see if the description tag was present and adjust output   accordingly
            $tags = NULL;
$tags = get_meta_tags($url);
if($tags)
echo "<tr><td>Description($url)</td><td>" .$tags['description']. "</td></tr>";
else 
echo "<tr><td>Description($url)</td><td>No Meta Description</td></tr>";
    }
}
?>

然后发布URL的。获取信息。

然后发布URL。GET is。

你发表评论很好,但不要评论每一行!“遍历url”这一点从代码本身就可以明显看出!GET方法实际上并不适用于长数据。改用POST。谢谢!好吧,我会限制我的评论;)你发表评论很好,但不要评论每一行!“遍历url”这一点从代码本身就可以明显看出!GET方法实际上并不适用于长数据。改用POST。谢谢!好吧,我会限制我的评论;)