Hi James,
Yes, I'm displaying just the contents. 
The php doesn't display, but it's there if anyone looks at the source.

Tried it with an "s":-
$contents = preg_replace("/<\?.+\?>/s", "", $contents);
but it also removes all the html.

There's an include header at the beginning, 
some html tags with the content and the odd php,
then an include footer at the end.

It must see the first "<?php" then remove everything including the html, right 
through to the last closing "?>"


----- Original Message ----- 
From: "James Keeline" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 21, 2005 7:01 AM
Subject: Re: [php-list] regex problem


> --- Bob <[EMAIL PROTECTED]> wrote:
> 
>> I'd like to strip out php content from a page for a printer friendly version.
>> I tried this below. Only works if the php is on one line.
>> Ignores any php that has multiple lines.
>> 
>> $contents = preg_replace("/<\?.+\?>/", "", $contents);
>> 
>> Anyone tell me what I'm doing wrong?
> 
> 
> There are modifiers which can be applies to Perl-compatable regular
> expressions.  In this case you could add "s" after the trailing slash:
> 
>  /<\?.+\?>/s
> 
> This allows the match to span multiple lines rather than cease at the end of
> the first newline encountered.
> 
> Under normal circumstances PHP code should not be displayed in an external web
> browser.  However, I assume you are displaying the contents of external files
> from within a PHP program.
> 
> James



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to