可以获取任意Web页面HTML代码的PHP函数
时间:2021-07-01 10:21:17
帮助过:4人阅读
- function display_sourcecode($url)
- {
- $lines = file($url);
- $output = "";
- foreach ($lines as $line_num => $line) {
- // loop thru each line and prepend line numbers
- $output.= "Line #{$line_num} : " . htmlspecialchars($line) . "
\n"; - }
- }
用法: - $url = "http://www.open-open.com";
- $source = display_sourcecode($url);
- echo $source;
- ?>
|
Web, HTML, PHP