Can anyone show an example how you create printer friendly. I using php 4.32
Error message
Warning: fopen(http://localhost/pcmag/1.php) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 401 Access Denied in D:\projects\pcmag\pfv.php on line 31
Warning: fread(): supplied argument is not a valid stream resource in D:\projects\pcmag\pfv.php on line 31
Notice: Undefined variable: code in D:\projects\pcmag\pfv.php on line 47
<a href="pfv.php" target="_blank"><strong>printer friednly version</strong></a>
<!-- CONTENT -->
TESTING TESTING
<!-- /CONTENT -->
<?php
/*
You can do whatever you like with this script. It's simple, but extremely useful if you're a programming newbiw.
This script is designed to allow someone to print just the content on a page without all the navigation elements. It looks for two comments tags in your HTML page:
<!-- CONTENT --> and <!-- /CONTENT -->
Anything in between these two comment tags will be returned to the browser.
The script will also print the address of the original content page at the bottom of the printer-friendly page. If you don't want it, remove the line '<br clear="all"><em>'.$HTTP_REFERER.'</em>'
Step 1. Save this script in a common area on your site. It does not have to be in your cgi-bin since it is not a cgi script, and you do not have to change its permissions.
Step 2. Replace the comments below in the script with your information.
Step 3. Open your HTML page and insert <!-- CONTENT --> and <!-- /CONTENT --> around your main content.
Step 4. Outside of the <!-- CONTENT --> and <!-- /CONTENT --> tags, add a link to this script, like:
<a href="pfv.php">Printer-friendly version</a>
If you want, you can add a small printer-looking icon in your link. You can find them lots of places online, like Mapquest.
That's it!
*/
$HTTP_REFERER = $_SERVER["HTTP_REFERER"];
$fd= fread(fopen($HTTP_REFERER, "r"), 100000);
if ($fd)
{
$start= strpos($fd, "<!-- CONTENT -->");
$finish= strpos($fd, "<!-- /CONTENT -->");
$length= $finish-$start;
$code=Substr($fd, $start, $length);
}
echo '<html>
<head>
<title>/* enter a generic title for your site, which will appear in the title bar of the browser window */</title>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
'.$code.'
<br clear="all"><em>'.$HTTP_REFERER.'</em>
</body>
</html>';
?>