RE: [PHP] stripping white space?

2001-07-10 Thread Brian White

You just gotta love religious wars.

How many people know about SGML? HTML is a standard implemented in SGML, and
so has many of the possible features of SGML which got excluded for XML such as
   * ommissible end tags
   * optional quotes on attribute values that don't contain spaces or quotes
   * implied attribute values
   * ommissible attribute names ( eg for things like "checked" )

Anyway. Not wading in to the debate. Just making an observation

At 02:20 10/07/2001 -0500, Navid A. Yar wrote:
>I guess this is just one of those things where everyone's opinions runs in
>different directions, yet everyone is entitled to their own. I myself try to
>respect the standard because of the browser war years which made everyone
>uncomfortable. Now most browsers are trying to merge into a single standard
>(thank god). I believe the future to be XML, and I also don't think HTML
>will ever go away. However, I do believe that HTML will be treated more
>strict (hence the emergence of XHTML which is based on HTML 4.0 and XML). My
>suggestion to everyone is to continue using standards and try not to go
>astray from them, else we know the headaches us developers can face in the
>future.
>
>Sincerely,
> Navid Yar
>
>
>-Original Message-
>From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, July 10, 2001 1:06 AM
>To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
>Subject: RE: [PHP] stripping white space?
>
>
>Yeah, I know that XML requires it. And I also know that it is not a good
>code practice, but it perfectly works for HTML pages. Browsers compatible
>with the style sheets have no problems with this code (there's no
>connection), and if there's any XML to work on the HTML will be rewritten
>anyway, so there's really no reason to worry about it. Just the size gets
>lower and typing (escaping in PHP) is easier. I think it IS a good practice
>if you only practicing HTML to be outputted by PHP.
>
>
>Sincerely,
>
>  Maxim Maletsky
>  Founder, Chief Developer
>  PHPBeginner.com (Where PHP Begins)
>  [EMAIL PROTECTED]
>  www.phpbeginner.com
>
>
>
>
>-Original Message-
>From: Navid A. Yar [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, July 10, 2001 2:40 PM
>To: [EMAIL PROTECTED]
>Subject: RE: [PHP] stripping white space?
>
>
>If you do this then those who will want to eventually convert their projects
>over to XML or XHTML format will have a hard time doing so, because the
>double quotes around the values of the attributes are required. Also, it's
>not good code practice. Just something for future reference...
>
>-Original Message-
>From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, July 10, 2001 12:16 AM
>To: '[EMAIL PROTECTED]'; Kurt Lieber; [EMAIL PROTECTED]
>Subject: RE: [PHP] stripping white space?
>
>
>I would not be stripping white spaces, but double white spaces into single '
>';
>
>for example:
>
>$html = ereg_replace("[[:space:]]+", ' ', $page);
>
>I never tested this, but what I am trying to do is to get all and any blank
>characters and replace them with one single space. Why? Because I don't want
>all the words in text to merge together.
>
>This should reduce the size.
>
>Also here's a tip: remove any double or single quotes in tags surrounding
>integers. This is compatible enough, but is a bunch of bytes.
>
>i.e.:
>
>change every
>align="left">
>
>to
>
>align="left">
>
>this example is reduced by 6 bytes.
>
>
>
>Sincerely,
>
>  Maxim Maletsky
>  Founder, Chief Developer
>  PHPBeginner.com (Where PHP Begins)
>  [EMAIL PROTECTED]
>  www.phpbeginner.com
>
>
>
>
>-Original Message-
>From: Mukul Sabharwal [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, July 10, 2001 2:05 PM
>To: Kurt Lieber; [EMAIL PROTECTED]
>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 <[EMAIL PROTECTED]> 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
> > th

RE: [PHP] stripping white space?

2001-07-10 Thread Chadwick, Russell


there is a limit of # of root entries. But the number of files per directory
is much higher.  Running RH6.2 I tried this test: I have an SGI xfs
partition that does billion of entries per directory, like reiser, but for
an ext2 partition this perl script is for testing

for ($index = 1; $index <= 2097153; $index++) {
open (OUT, "> file_$index.txt");
print OUT "Test\n";
close (OUT);
}

after letting it run 4 hours :)  it seems to stop at 811626 where I run out
of disk space :)
oh well 

-Original Message-
From: Christian Reiniger [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 9:52 AM
To: Maxim Maletsky; 'Bart Veldhuizen'; [EMAIL PROTECTED]
Subject: Re: [PHP] stripping white space?


On Tuesday 10 July 2001 11:26, Maxim Maletsky wrote:

> But you're right, on UNIX systems, if I am not wrong, you cannot hold
> more then 1024 (?) files in a single directory.

AFAIK there's no limit (and certainly not 1024 files), but with most 
filesystems accesses on large directories are painfully slow. FSs such as 
ReiserFS however don't slow down noticeably on large directories...

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

I sat laughing snidely into my notebook until they showed me a PC running
Linux. And oh! It was as though the heavens opened and God handed down a
client-side OS so beautiful, so graceful, and so elegant that a million
Microsoft developers couldn't have invented it even if they had a hundred
years and a thousand crates of Jolt cola.

- LAN Times

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-10 Thread Bart Veldhuizen

Hi Remo,

> PS: Can anyone enlighten me concerning HTTP compression?

I wish I could remember where I read this, but the PHP documentation still
does not have this feature described. To enable zlib output compression,
first make sure you have compiled PHP with the --with-zlib option. Next, add
the following line to php.ini:

zlib.output_compression = On


That's all there is to it!

Have fun,

Bart



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-10 Thread Bart Veldhuizen

Hi Maxim,

I wrote a mini-manual about the module. You can get it with the code from:

http://helium.homeip.net/stuff/cache.tar.gz

I hope it helps you and I look forward to suggestions and contributions!

Bart


"Maxim Maletsky" <[EMAIL PROTECTED]> wrote in message
news:DC017B079D81D411998C009027B7112A015ED390@EXC-TYO-01...
>
> > /cache/data/articles/0-24/...
> > /cache/data/articles/25-50/...
> > /cache/data/searches/...
>
> this was our original idea, the difficulty is that there's the need to
> access this directory from several places (mod_rewrite, php and postrges).
> It is easy to access but might be hard to combine the URL together.
>
> But you're right, on UNIX systems, if I am not wrong, you cannot hold more
> then 1024 (?) files in a single directory.
> So subfolders is the way to go.
>
> Cheers,
> Maxim Maletsky
>
>
>
> -Original Message-
> From: Bart Veldhuizen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 10, 2001 6:07 PM
> To: Maxim Maletsky; [EMAIL PROTECTED]
> Subject: Re: [PHP] stripping white space?
>
>
> Hi Maxim,
>
> > I am definitely interested in seeing your caching modules - it could be
a
> > useful resource for ours.
> > Right now our caching module is only in the planning stage, but there
are
> > few scratches I wrote myself, and it seems to be very promising.
>
> I'll do my best to write a short blurb on how to use it today and publish
> the code. I also have to do a zillion other things (like work on my new
> house), so I can't promise it'll actually be there today!
>
> > There's a directory called /cached which we will store the file with the
> > exactly same file names (with mod_rewrite there's no need to use any
> > ?var=val&etc=etc&, you just get it looking like a directory) so it is
> > extremely easy to locate a file.
> >
> > ie: if you go to a file
> >
> >articles/2000/10/26/features/doom
> >
> > then apache looks first into
> >
> >cached/articles-2000-10-26-features-doom.txt
>
> I can see one problem that you're gonna run into and that is that this
> directory will contain thousands of files. Not many OS's can handle that.
In
> our case, each article has an article ID and the caching module
> automatically creates subdirectories that will hold a number of cached
> pages. Additionally, I can assign page 'types' to a page. These will
> generate new subdirectories as well. My caching directory looks like this:
>
> /cache/data/articles/0-24/...
> /cache/data/articles/25-50/...
> /cache/data/searches/...
>
> Have fun,
>
> Bart
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-10 Thread Bart Veldhuizen

Hi Maxim,

> 1. HTTP compression, which is not 100% compatible, but catches most
> of the browsers anyway.

Yes. The standard PHP implementation actually inspects the HTTP headers to
determine if the browser supports gzip encoding. If not, it will send the
files uncompressed. Looking at our website stats, 97%+ of the people use a
version 4 browser so they're fine.

> 2. Our own caching system: in two words: ob_*() to save the output
> as a text file, mod_rewrite to check for file and throw the plain .txt
files
> if exist, PostgreSQL triggers to update (delete cached) .txt files.

Hah! We think alike :) I implemented a similar system on our own website a
few weeks ago. It does not cache complete pages (that's hardly possible due
to the dynamic nature of our site), but instead caches HTML 'blocks'.  (one
page can consist of multiple blocks). Instead of serving those files
directly from the filesystem I let PHP inspect them first: each file
contains a timestamp that allows for expiry times.

The results are wonderful: our website (http://www.blender.nl) has
approximately 80.000 pageviews a day and the system load is almost never
higher than 0.4. (Dual PIII/450/512MB/FreeBSD)

If people are interested I'll publish the code for the caching module.

> 3. Browser/Platform detection: there's no need to make
> cross-platform heavy but compatible pages, just specific style sheets and
> html tags for specific browser families.

Clever! That's something I will put on my to-do list as well.

> 4. clever HTML design, so there are less tags, tables etc, to have
> files smaller. And *that* also includes less comments and double quotes on
> integers. We do nothing with XML, so that is why I am so shocked why
people
> here discourage me that much.

In my experience once you use HTTP compression, adding a few comments or
whitelines do hardly add to the filesize anymore. I don't think it's worth
the trouble to write super-compact HTML.

I don't know a single thing about XML, so I'll skip that discussion :)

Bart



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] stripping white space?

2001-07-09 Thread Navid A. Yar

I guess this is just one of those things where everyone's opinions runs in
different directions, yet everyone is entitled to their own. I myself try to
respect the standard because of the browser war years which made everyone
uncomfortable. Now most browsers are trying to merge into a single standard
(thank god). I believe the future to be XML, and I also don't think HTML
will ever go away. However, I do believe that HTML will be treated more
strict (hence the emergence of XHTML which is based on HTML 4.0 and XML). My
suggestion to everyone is to continue using standards and try not to go
astray from them, else we know the headaches us developers can face in the
future.

Sincerely,
Navid Yar


-Original Message-
From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 1:06 AM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP] stripping white space?


Yeah, I know that XML requires it. And I also know that it is not a good
code practice, but it perfectly works for HTML pages. Browsers compatible
with the style sheets have no problems with this code (there's no
connection), and if there's any XML to work on the HTML will be rewritten
anyway, so there's really no reason to worry about it. Just the size gets
lower and typing (escaping in PHP) is easier. I think it IS a good practice
if you only practicing HTML to be outputted by PHP.


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Navid A. Yar [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 2:40 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] stripping white space?


If you do this then those who will want to eventually convert their projects
over to XML or XHTML format will have a hard time doing so, because the
double quotes around the values of the attributes are required. Also, it's
not good code practice. Just something for future reference...

-Original Message-
From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 12:16 AM
To: '[EMAIL PROTECTED]'; Kurt Lieber; [EMAIL PROTECTED]
Subject: RE: [PHP] stripping white space?


I would not be stripping white spaces, but double white spaces into single '
';

for example:

$html = ereg_replace("[[:space:]]+", ' ', $page);

I never tested this, but what I am trying to do is to get all and any blank
characters and replace them with one single space. Why? Because I don't want
all the words in text to merge together.

This should reduce the size.

Also here's a tip: remove any double or single quotes in tags surrounding
integers. This is compatible enough, but is a bunch of bytes.

i.e.:

change every


to



this example is reduced by 6 bytes.



Sincerely,

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Mukul Sabharwal [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 2:05 PM
To: Kurt Lieber; [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>


=
*
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [E

Re: [PHP] stripping white space?

2001-07-09 Thread Bart Veldhuizen

Hi Brian,

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

You can already achieve this by using the built-in output buffering
function. Read http://www.zend.com/manual/function.ob-start.php for more
information and a simple example on this.

Why not go for HTTP compression though? The gain would be much larger than
just stripping out the whitespace/comments and such..

Have fun,

Bart




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-09 Thread Mark Charette

From: "Maxim Maletsky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, July 10, 2001 1:05 AM
Subject: RE: [PHP] stripping white space?


> I think it IS a good practice
> if you only practicing HTML to be outputted by PHP.

Why, if you know that it's illegal XHTML and XML, would you ever conclude
that it's _good_ practice to break the rules? Saving 20 or 30 bytes/page? If
you really want some space saving on many browsers and you're running Apache
why not just install the zlib package? Effective throughtput on my (over
100,000) pages on my site jumped 8-fold for those people able to receive and
decode zlib-compressed pages, and I didn't have to change anything ...

Mark C.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-09 Thread Brian White

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:
>
>
> 
>
>into just 
>
>You'd have to check for a bit more, such as  and  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  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" <[EMAIL PROTECTED]>
>To: "Kurt Lieber" <[EMAIL PROTECTED]>
>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 " " from "Hello
> > World!"
> >
> > /* Chris Lambert, CTO - [EMAIL PROTECTED]
> > WhiteCrown Networks - More Than White Hats
> > Web Application Security - www.whitecrown.net
> > */
> >
> > - Original Message -
> > From: Kurt Lieber <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > 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:
> > |
> > | 
> > |   
> > |   
> > |   Hello World!
> > |   
> > |   
> > | 
> > |
> > | The client will receive the HTML as:
> > |
> > | Hello World!
> > |
> > | 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" <[EMAIL PROTECTED]>
> > | To: "Kurt Lieber" <[EMAIL PROTECTED]>;
> > <[EMAIL PROTECTED]>
> > | 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 <[EMAIL PROTECTED]> 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.
> > | > >
&g

RE: [PHP] stripping white space?

2001-07-09 Thread Navid A. Yar

If you do this then those who will want to eventually convert their projects
over to XML or XHTML format will have a hard time doing so, because the
double quotes around the values of the attributes are required. Also, it's
not good code practice. Just something for future reference...

-Original Message-
From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 12:16 AM
To: '[EMAIL PROTECTED]'; Kurt Lieber; [EMAIL PROTECTED]
Subject: RE: [PHP] stripping white space?


I would not be stripping white spaces, but double white spaces into single '
';

for example:

$html = ereg_replace("[[:space:]]+", ' ', $page);

I never tested this, but what I am trying to do is to get all and any blank
characters and replace them with one single space. Why? Because I don't want
all the words in text to merge together.

This should reduce the size.

Also here's a tip: remove any double or single quotes in tags surrounding
integers. This is compatible enough, but is a bunch of bytes.

i.e.:

change every


to



this example is reduced by 6 bytes.



Sincerely,

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Mukul Sabharwal [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 2:05 PM
To: Kurt Lieber; [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>


=
*
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-09 Thread Kurt Lieber

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:




into just 

You'd have to check for a bit more, such as  and  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  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" <[EMAIL PROTECTED]>
To: "Kurt Lieber" <[EMAIL PROTECTED]>
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 " " from "Hello
> World!"
>
> /* Chris Lambert, CTO - [EMAIL PROTECTED]
> WhiteCrown Networks - More Than White Hats
> Web Application Security - www.whitecrown.net
> */
>
> - Original Message -
> From: Kurt Lieber <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> 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:
> |
> | 
> |   
> |   
> |   Hello World!
> |   
> |   
> | 
> |
> | The client will receive the HTML as:
> |
> | Hello World!
> |
> | 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" <[EMAIL PROTECTED]>
> | To: "Kurt Lieber" <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> | 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 <[EMAIL PROTECTED]> 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:
> | > > [EMAIL PROTECTED]
> | > > For additional commands, e-mail:
> | > > [EMAIL PROTECTED]
> | > > To contact the list administrators, e-mail:
> | > > [EMAIL PROTECTED]
> | > >
> | >
> | >
> | > =
> | > *
> | > 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: [EMAIL PROTECTED]
> | > For additional commands, e-mail: [EMAIL PROTECTED]
> | > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> | >
> | >
> |
> |
> | --
> | PHP General Mailing List (http://www.php.net/)
> | To unsubscribe, e-mail: [EMAIL PROTECTED]
> | For additional commands, e-mail: [EMAIL PROTECTED]
> | To contact the list administrators, e-mail: [EMAIL PROTECTED]
> |
> |
> |
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-09 Thread Kurt Lieber

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:


  
  
  Hello World!
  
  


The client will receive the HTML as:

Hello World!

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" <[EMAIL PROTECTED]>
To: "Kurt Lieber" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]> 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:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> >
>
>
> =
> *
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] stripping white space?

2001-07-09 Thread Jack Dempsey

You can't do that...deleting ALL spaces will screw up your content...
Try str_replace("\n","",$var) to strip newlines, then a
preg_replace("/\s+/"," ",$var) to strip all multiple spaces down to
one...
Haven't tested this syntax, but should be about right...

jack

-Original Message-
From: Mukul Sabharwal [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 10, 2001 1:05 AM
To: Kurt Lieber; [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 


=
*
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripping white space?

2001-07-09 Thread Mukul Sabharwal

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 <[EMAIL PROTECTED]> 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:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 


=
*
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]