RE: [PHP] stripping white space?

From: Date: Tue, 10 Jul 2001 06:12:53 +0000
Subject: RE: [PHP] stripping white space?
Groups: php.general 
Request: Send a blank email to php-general+get-57083@lists.php.net to get a copy of this message
... Use FTP combined with C++, Java, Perl or better Shell Scripting to do that. Upload the file through FTP into a directory, write a shell script that does the filtering of your files (I use it to strip comments out the PHP code and to remove useless staff). Easier. But, often not reliable. I just took some time having fun on this idea. I wrote a little file in C++ that was running couple minutes under cron or on a request, taking the freshly uploaded files from a temp directory, renamed it, filtered it and then archived the activities on the server. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Brian White [mailto:bwhite@steptwo.com.au] Sent: Tuesday, July 10, 2001 2:46 PM To: Kurt Lieber; Chris Lambert - WhiteCrown Networks; php-general@lists.php.net Subject: Re: [PHP] stripping white space? This sounds like that could be done in PHP - but it would be an AWFUL lot of work and fiddle to get right. I personally wouldn't even consider it unless you had way to hook in to the final output of PHP. Possibilities ( not all of them sane ): * Modify PHP. Add an INI var for turning the feature on and off which defaults to off. * Persuade someone at Zend to modify PHP so that a filter function can be specified which all output text is passed through - would have the same restrictions as the "header" function * Call PHP from within PHP or Perl - call the original script directly using the PHP binary and then parse the text output to create munged HTML. ( Horribly inefficient ) * Wait until Apache 2.0 allows you to chain outputs. Regs Brian White At 22:39 9/07/2001 -0700, Kurt Lieber wrote: >Well, you can simply look for a closing bracket (>) followed by only white >space characters (space, tab, return) followed by an open bracket (<) and, >if there's a match, strip out the white space in between them. That would >turn: > ><tr> > <td> > >into just <tr><td> > >You'd have to check for a bit more, such as <pre> and <code> tags, but >it's >not an unreasonable regex to write. What I am more concerned about is; I'm >assuming everything would have to be encased within <?php ?> tags, meaning >all HTML would have to be properly escaped, etc. *that* would be a major >pain, so I hope I'm overlooking something. > > >--kurt >----- Original Message ----- >From: "Chris Lambert - WhiteCrown Networks" <chris@whitecrown.net> >To: "Kurt Lieber" <php@internalcombustion.com> >Sent: Monday, July 09, 2001 10:11 PM >Subject: Re: [PHP] stripping white space? > > > > Nothing can _easily_ do this, as HTML puts formatting and content on the > > same page. You can strip new lines, you can strip tabs, and you can strip > > consecutive spaces, but there's no way to tell "<tr> <td>" from > > "Hello > > World!" > > > > /* Chris Lambert, CTO - chris@whitecrown.net > > WhiteCrown Networks - More Than White Hats > > Web Application Security - www.whitecrown.net > > */ > > > > ----- Original Message ----- > > From: Kurt Lieber <php@internalcombustion.com> > > To: <mukulsabharwal@yahoo.com>; <php-general@lists.php.net> > > Sent: Tuesday, July 10, 2001 1:14 AM > > Subject: Re: [PHP] stripping white space? > > > > > > | nope -- I want to completely suppress any extraneous white space > > characters > > | (tabs, spaces, etc.) in the HTML as it's being delivered to the client. > > So, > > | where your source file might look like: > > | > > | <table> > > | <tr> > > | <td> > > | Hello World! > > | </td> > > | <tr> > > | </table> > > | > > | The client will receive the HTML as: > > | > > | <table><tr><td>Hello World!</td></tr></table> > > | > > | all on one big long line. But your source file maintains the original > > | formatting for easy readability. > > | > > | I'm guessing the answer is no, PHP can't (easily) do this but I just > > thought > > | I'd check. > > | > > | --kurt > > | ----- Original Message ----- > > | From: "Mukul Sabharwal" <mukulsabharwal@yahoo.com> > > | To: "Kurt Lieber" <php@internalcombustion.com>; > > <php-general@lists.php.net> > > | Sent: Monday, July 09, 2001 10:04 PM > > | Subject: Re: [PHP] stripping white space? > > | > > | > > | > Hi, > > | > > > | > I take that you simply want to remove ALL whitespaces > > | > from a data block (variable). > > | > > > | > you could simply use str_replace(" ", "", $var); > > | > > > | > > > | > > > | > --- Kurt Lieber <php@internalcombustion.com> wrote: > > | > > Is there a way using PHP to easily strip white space > > | > > out of an html page as > > | > > it's being sent to the client. That is to say, the > > | > > page that we as > > | > > developers work on is nicely formatted, indented, > > | > > etc. but when it's sent > > | > > out to the client, PHP will remove all the extra > > | > > white space both to > > | > > obfuscate the code and reduce the size a bit. > > | > > > > | > > For anyone who knows Cold Fusion, I'm looking for > > | > > the PHP equivalent of the > > | > > "Suppress whitespace by default" option in the Cold > > | > > Fusion Server > > | > > Administrator. > > | > > > > | > > (NOTE: I'm not looking for a discussion on the > > | > > merits of stripping vs. not > > | > > stripping white space characters or whether or not > > | > > it really does any > > | > > good -- I just want to know if it can be done easily > > | > > using PHP) > > | > > > > | > > Thanks. > > | > > > > | > > --kurt > > | > > > > | > > > > | > > -- > > | > > PHP General Mailing List (http://www.php.net/) > > | > > To unsubscribe, e-mail: > > | > > php-general-unsubscribe@lists.php.net > > | > > For additional commands, e-mail: > > | > > php-general-help@lists.php.net > > | > > To contact the list administrators, e-mail: > > | > > php-list-admin@lists.php.net > > | > > > > | > > > | > > > | > ===== > > | > ********************************* > > | > http://www.geocities.com/mimodit > > | > ********************************* > > | > > > | > __________________________________________________ > > | > Do You Yahoo!? > > | > Get personalized email addresses from Yahoo! Mail > > | > http://personal.mail.yahoo.com/ > > | > > > | > -- > > | > PHP General Mailing List (http://www.php.net/) > > | > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > | > For additional commands, e-mail: php-general-help@lists.php.net > > | > To contact the list administrators, e-mail: >php-list-admin@lists.php.net > > | > > > | > > > | > > | > > | -- > > | PHP General Mailing List (http://www.php.net/) > > | To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > | For additional commands, e-mail: php-general-help@lists.php.net > > | To contact the list administrators, e-mail: php-list-admin@lists.php.net > > | > > | > > | > > > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------------------------- Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#57083) next »