您的位置:首页 > 编程语言 > PHP开发

php 获取网页内容及代码

2010-07-23 10:47 561 查看
<?php
$url = "http://localhost/cp/test.html";
$contents = file_get_contents($url);
//如果出现中文乱码使用下面代码
$getcontent = iconv("gb2312", "utf-8",$contents);
echo $getcontent;
?>


<?php
$lines = file('http://localhost/cp/test.html');
foreach ($lines as $line_num => $line) {
echo "Line <b>{$line_num}</b> : " . htmlspecialchars($line). "<br />/n";
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: