Opening file

This is a discussion on Opening file within the PHP General forums, part of the PHP Programming Forums category; Hi list, I have been trying to make "printer friendly version" feature for a web site and have ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2007
ed gregory
 
Posts: n/a
Default Opening file


Hi list,

I have been trying to make "printer friendly version" feature for a
web site and have encountered a problem. Each page of the web site is
composed of a header.php, footer.php and the content of the page which
uses "include_once" to include the above mentioned pages. I have tried
all known methods of reading the file I want to have "printer friendly
version" for, but all of them return a complete page (page with code
of footer.php and header.php included, and not the original).

So, here is what I get:
***********************
<html>
<title>aaa</title>
<body>
some content here
</body>
</html>
***********************

And what I need is:
***********************
<?
include_once "header.php"
?>
some content here
<?
include_once "footer.php"
?>
***********************

After I get the original code I can exclude the "include" php tags and
print only the main content.

So, the question is: is there any way (except for FTP functions) to
solve this?

Thank you.

Best regards,
Ed

--
http://www.freenet.am/
Reply With Quote
  #2 (permalink)  
Old 04-26-2007
Zoltán Németh
 
Posts: n/a
Default Re: [PHP] Opening file

2007. 04. 26, csütörtök keltezéssel 23.19-kor ed gregory ezt Ã*rta:
> Hi list,
>
> I have been trying to make "printer friendly version" feature for a
> web site and have encountered a problem. Each page of the web site is
> composed of a header.php, footer.php and the content of the page which
> uses "include_once" to include the above mentioned pages. I have tried
> all known methods of reading the file I want to have "printer friendly
> version" for, but all of them return a complete page (page with code
> of footer.php and header.php included, and not the original).
>
> So, here is what I get:
> ***********************
> <html>
> <title>aaa</title>
> <body>
> some content here
> </body>
> </html>
> ***********************
>
> And what I need is:
> ***********************
> <?
> include_once "header.php"
> ?>
> some content here
> <?
> include_once "footer.php"
> ?>
> ***********************
>
> After I get the original code I can exclude the "include" php tags and
> print only the main content.
>
> So, the question is: is there any way (except for FTP functions) to
> solve this?


well you either execute the script and get the result as in your first
example, or you either read the php file (using file() or fread() or
something) but then it won't be executed at all, which would give you
php code instead of the markup you want

I've done printer friendly version once as a separate "mode" of the
page, in which case I echoed only the stuff needed for the printer
friendly version

greets
Zoltán Németh

>
> Thank you.
>
> Best regards,
> Ed
>
> --
> http://www.freenet.am/
>

Reply With Quote
  #3 (permalink)  
Old 04-27-2007
Jonathan
 
Posts: n/a
Default Re: [PHP] Opening file

Zoltán Németh wrote:
> 2007. 04. 26, csütörtök keltezéssel 23.19-kor ed gregory ezt Ã*rta:
>> Hi list,
>>
>> I have been trying to make "printer friendly version" feature for a
>> web site and have encountered a problem. Each page of the web site is
>> composed of a header.php, footer.php and the content of the page which
>> uses "include_once" to include the above mentioned pages. I have tried
>> all known methods of reading the file I want to have "printer friendly
>> version" for, but all of them return a complete page (page with code
>> of footer.php and header.php included, and not the original).
>>
>> So, here is what I get:
>> ***********************
>> <html>
>> <title>aaa</title>
>> <body>
>> some content here
>> </body>
>> </html>
>> ***********************
>>
>> And what I need is:
>> ***********************
>> <?
>> include_once "header.php"
>> ?>
>> some content here
>> <?
>> include_once "footer.php"
>> ?>
>> ***********************
>>
>> After I get the original code I can exclude the "include" php tags and
>> print only the main content.
>>
>> So, the question is: is there any way (except for FTP functions) to
>> solve this?

>
> well you either execute the script and get the result as in your first
> example, or you either read the php file (using file() or fread() or
> something) but then it won't be executed at all, which would give you
> php code instead of the markup you want
>
> I've done printer friendly version once as a separate "mode" of the
> page, in which case I echoed only the stuff needed for the printer
> friendly version
>
> greets
> Zoltán Németh
>
>> Thank you.
>>
>> Best regards,
>> Ed
>>
>> --
>> http://www.freenet.am/
>>


Ed you may consider using CSS for screen and print versions.
Reply With Quote
  #4 (permalink)  
Old 04-27-2007
Jay Blanchard
 
Posts: n/a
Default RE: [PHP] Opening file

[snip]
I have been trying to make "printer friendly version" feature for a
web site
[/snip]

Use CSS to control what prints.
http://www.google.com/search?hl=en&q=printing+with+CSS
Reply With Quote
  #5 (permalink)  
Old 04-27-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Opening file

On Thu, April 26, 2007 2:19 pm, ed gregory wrote:
>
> Hi list,
>
> I have been trying to make "printer friendly version" feature for a
> web site and have encountered a problem. Each page of the web site is
> composed of a header.php, footer.php and the content of the page which
> uses "include_once" to include the above mentioned pages. I have tried
> all known methods of reading the file I want to have "printer friendly
> version" for, but all of them return a complete page (page with code
> of footer.php and header.php included, and not the original).
>
> So, here is what I get:
> ***********************
> <html>
> <title>aaa</title>
> <body>
> some content here
> </body>
> </html>
> ***********************
>
> And what I need is:
> ***********************
> <?
> include_once "header.php"
> ?>
> some content here
> <?
> include_once "footer.php"
> ?>
> ***********************
>
> After I get the original code I can exclude the "include" php tags and
> print only the main content.


<?php
$html = file_get_contents("http://freenet.am");
preg_match("|<body[^>]>(.*)</body>|msi", $html, $body);
echo htmlentities($body):
?>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:52 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0