---
title: "PHP 获取网页title"
author: "javaeyeren"
date: "2009-02-02T01:41:00Z"
tags: []
slug: "php-title"
draft: false
lastmod: "2009-02-02T01:41:00Z"
id: 601352
url: "https://javaeyeren.iteye.com/blog/601352"
---

&lt;?php  
$url = 'http://sohu.com';  
$lines\_array = file($url);  
echo $lines\_array;  
echo "&lt;br/&gt;";  
$lines\_string = implode('', $lines\_array);  
eregi("&lt;title&gt;(.\*)&lt;/title&gt;", $lines\_string, $head);  
echo "head:".$head;  
echo "&lt;br/&gt;";  
print\_r($head);  
echo "&lt;br/&gt;";  
echo "title:".$head\[1];

?&gt;