PHP头条
热点:

php怎么通过地址去获取一个网页的标题title里面的内容


php如何通过地址去获取一个网页的标题title里面的内容。
比如,我在文本框里面输入一个网址。点击“获取标题”按钮,如何才能获取到标题并写入到下面的文本框里面。
分享到:
------解决方案--------------------
一个后端页面 gettitle.php (代码我复制的,没测试)


function get_title($html)
{
  $html=strtolower($html);
$title = str_replace(" - ",",",cut($html,"", "" ));
//if ($title == "") $title = "无标题";
if ($title) $title=replace_word(textcut($title,80));
if ($title) $title=preg_replace("/<(.*?)>/","",$title);
return addslashes(trim($title));
}


你的前端页面 点击获取标题后 触发 ajax 到后端页面 取得返回的json 或字符串 赋值给你的相应input value

www.phpzy.comtrue/phprm/8393.htmlTechArticlephp怎么通过地址去获取一个网页的标题title里面的内容 php如何通过地址去获取一个网页的标题title里面的内容。 比如,我在文本框里面输入一个网址。点击“获取标题”按钮,如何才能...

相关文章

相关频道:

PHP之友评论

今天推荐