Home  >  Article  >  Backend Development  >  PHP obtains the implementation code of web page source code and web page title

PHP obtains the implementation code of web page source code and web page title

WBOY
WBOYOriginal
2016-07-25 08:56:201389browse
  1. $lines = file('http://bbs.it-home.org/');
  2. foreach ($lines as $line_num => $line) {
  3. echo "Line {$line_num} : " . htmlspecialchars($line) . "
    n";
  4. }
  5. ?>
复制代码

2,获取网页的标题:

  1. $url = 'http://bbs.it-home.org';
  2. $lines_array = file($url);
  3. echo $lines_array;
  4. echo "
    ";
  5. $lines_string = implode('', $lines_array);
  6. eregi("(.*)", $lines_string, $head);
  7. echo "head:".$head;
  8. echo "
    ";
  9. print_r($head);
  10. echo "
    ";
  11. echo "title:".$head[1];
  12. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn