--- 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
_____


James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Summer Semester Begins Jun 20 -- New Classes Start Every Few Weeks.


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