if the header and footer info come from your config.php file, then you have
to get to that file before it's parsed by the server.  Perhaps, splitting
config.php into three files (header.php, config.php and footer.php), then
when you want to print just call the middle file.

if(isset($_GET['print'])) include("config.php");  // printer version
if(!isset($_GET['print'])) // regular page view
    {
    include("header.php");
    include("config.php");
    include("footer.php");
    }
Hope this helps.
Hugh

----- Original Message -----
From: "Sebastian" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 10:23 PM
Subject: Re: [PHP] Re: str_replace


> doesn't work but also doesn't give any errors, I will try to explain what
I
> am trying to do:
>
> I am trying to remove the header and footer to create a "printer friendly
> page" with just the content, here's what my pages look like, I need to
> remove header and footer when they visit: file.php?action=print
>
> <?php
> include("../config.php");
>
> if($_GET[action] == "print")
> {
>    $header = str_replace('include("$header");', '', $header);
>    $footer = str_replace('include("$footer");', '', $footer);
> }
>
> include("$header");
> ?>
>
> // html
>
> <?php include("$footer"); ?>
>
> cheers,
> - Sebastian
>
> ----- Original Message -----
> From: "John Gray" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, March 15, 2003 12:31 AM
> Subject: [PHP] Re: str_replace
>
>
> | $footer = str_replace('include("$header");', '', $footer);
> |
> | The way you have it now, you're telling PHP to first include the file
> | named by the variable $header, then do an str_replace on the result; but
> | the parser is going to fail on that first semi-colon, and that's not
> | what you want to do anyway (as I understand it). Put the line you want
> | to replace inside single quotes (as above) and PHP won't attempt to
> | parse it, it'll just treat it as a string literal. Hope this helps, hope
> | it makes sense.
> |
> | - john
> |
> | Sebastian wrote:
> | > This may seem weird:
> | >
> | > How do I str_replace an include function?
> | >
> | > I want to replace this line: include("$header");
> | >
> | > with nothing ..
> | >
> | > something like this:
> | >
> | > $footer = str_replace(" '. include("$header"); .' ", "", $footer);
> | >
> | > I get errors, any ideas?
> | >
> | > cheers,
> | > - Sebastian
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to