Re: Strip PHP tags

From: Date: Tue, 13 Aug 2002 02:11:17 +0000
Subject: Re: Strip PHP tags
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112236@lists.php.net to get a copy of this message
The only NATIVE way is using strip_tags(), and physically allowing most HTML tags to be included: $allowed = "<A><B><I><HTML><HEAD><SCRIPT><BODY><A><BR><HR><P><H1><H2><META><TABLE><TR>< TD><THEAD> etc etc"; $html = strip_tags($html, $allowed); In other words, I think you're better off with a regexp on this occasion. Second option: Depending on your code, something like: $html = str_replace('<?','<!--',$html); $html = str_replace('?>','-->',$html); MIGHT comment out all your PHP, but I'm thinking that it will depend greatly on your coding style, and is really just a quick hack. Justin French on 13/08/02 3:35 AM, Remy Dufour (rdufour@propage.com) wrote: > Hi all, > > Is there an easy way to remove <?php...?> tag from a string ? > Ive got this script and i want it to output only html... > I know i can do this with regular expression but i wonder if there are some > native function to do the job. > > <?php > $out = implode("\n", file ($_SERVER['PATH_TRANSLATED'])); > echo function_to_remove_php_tags($out); > exit(); > ?> > <html> > <head> > <title>Test</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > <body bgcolor="#FFFFFF" text="#000000"> > Hello !!! > </body> > </html> > > Regards ! > > Rémy Dufour >

« previous php.general (#112236) next »