PHP生成便于打印的网页
e <?=$page?>". "does not exist on this site.</strong>"; } else { // 得到页面的内容并把它放到一个字符串中 $fcontents = join('', file("$page.inc")); // 忽略颜色属性,转换以’ignore’替代’color’ $fcontents = ereg_replace(''color'',''ignore'',$fcontents); // 去除超链接中的 “_blank” $fcontents = ereg_replace(''target="_blank"'','',$fcontents); // 替换</a>标记 $fcontents = ereg_replace(''</a>'','',$fcontents); // 显示URL的绝对地址 $fcontents = ereg_replace(''<a[^h]*href="(http://[^"]*)"[^>]*>;([^]*)'', ''<strong>\2</strong><em>(\1)</em>'',$fcontents); // 把相对链接转为绝对链接 $fcontents = ereg_replace( ''<a[^h]*href="([^"]*)"[^>]*>([^]*)'', "<strong>\2</strong><em>(http://$HTTP_HOST/\1)</em>";, $fcontents); // 背景颜色改回白色 $fcontents = ereg_replace(''<body bgignore'',''<body bgcolor'', $fcontents); // if any markers left restore link end element $fcontents = ereg_replace('',''</a>'',$fcontents); // 输出页面 echo $fcontents; } ?> </td> </tr> <tr> <td align="center"><hr width="90%"></td> </tr> <tr> <td align="center"> <? include("$page_path/footer.inc"); ?> </td> </tr> </table> </font> </body> </html> 这样便于打印的页面就生成了,希望对大家能有帮助。 (译自PHPBulider/Mark Spink) |
查看所有评论
