- function display_sourcecode($url)
- {
- $lines = file($url);
- $output = "";
- foreach ($lines as $line_num => $line) {
- // loop thru each line and prepend line numbers
- $output.= "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
- }
- }
用法:
- <?php
- $url = "http://www.open-open.com";
- $source = display_sourcecode($url);
- echo $source;
- ?>
来源: http://www.phpxs.com/code/1002986/