Re: Re: optimilize web page loading
| From: | Robert Cummings | Date: | Fri, 28 Mar 2008 13:00:52 +0000 |
| Subject: | Re: Re: optimilize web page loading | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272215@lists.php.net to get a copy of this message | ||
On Fri, 2008-03-28 at 09:31 +0100, Zoltán Németh wrote:
> 2008. 03. 28, péntek keltezéssel 09.19-kor Zoltán Németh ezt írta:
> > 2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt írta:
> > > Jason Pruim wrote:
> > > >
> > > > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
> > > >> Al wrote:
> > > >>> Good point. I usually do use the single quotes, just happened to key
> > > >>> doubles for the email.
> > > >>>
> > > >>> Actually, it's good idea for all variable assignments.
> > > >>>
> > > >>> Philip Thompson wrote:
> > > >>>> On Mar 26, 2008, at 6:28 PM, Al wrote:
> > > >>>>> Depends on the server and it's load. I've strung
> > > >>>>> together some
> > > >>>>> rather large html strings and they aways take far less time than
> > > >>>>> the
> > > >>>>> transient time on the internet. I used to use OB extensively
> > > >>>>> until
> > > >>>>> one day I took the time to measure the difference. I don't
> > > >>>>> recall the
> > > >>>>> numbers; but, I do recall it was not worth the slight extra
> > > >>>>> trouble
> > > >>>>> to use OB.
> > > >>>>>
> > > >>>>> Now, I simple assemble by html strings with $report .=
> > > >>>>> "foo"; And
> > > >>>>> then echo $report at the end. It also makes the code very easy
> > > >>>>> to
> > > >>>>> read and follow.
> > > >>>>
> > > >>>> You might as well take it a step further. Change the above to:
> > > >>>>
> > > >>>> $report .= 'foo';
> > > >>>>
> > > >>>> This way for literal strings, the PHP parser doesn't have to
> > > >>>> evaluate
> > > >>>> this string to determine if anything needs to be translated (e.g.,
> > > >>>> $report .= "I like to $foo"). A minimal speedup, but
> > > >>>> nonetheless...
> > > >>>>
> > > >>>> ~Philip
> > > >>>>
> > > >>>>
> > > >>>>> Andrew Ballard wrote:
> > > >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al
> > > >>>>>> <news@ridersite.org> wrote:
> > > >>>>>>> You are really asking an HTML question, if you think
> > > >>>>>>> about it.
> > > >>>>>>>
> > > >>>>>>> At the PHP level, either use output buffering or
> > > >>>>>>> assemble all your
> > > >>>>>>> html string as a variable and
> > > >>>>>>> then echo it. The goal is to compress the string into
> > > >>>>>>> the minimum
> > > >>>>>>> number of packets.
> > > >>>>>> Yes, but do so smartly. Excessive string concatenation can
> > > >>>>>> slow
> > > >>>>>> things
> > > >>>>>> down as well. On most pages you probably won't notice
> > > >>>>>> much
> > > >>>>>> difference,
> > > >>>>>> but I have seen instances where the difference was painfully
> > > >>>>>> obvious.
> > > >>>>>> Andrew
> > > >>
> > > >> Yes and if your script takes .00000000000000000000000000000002 seconds
> > > >> to run using double quotes it will only take
> > > >> .000000000000000000000000000000019 seconds with single (depending upon
> > > >> how many quotes you have of course) :-)
> > > >
> > > > I'm coming in late to this thread so sorry if I missed this :)
> > > >
> > > > How much of a difference would it make if you have something like this:
> > > > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar
> > > > bar bar
> > > > bar" . $foo $foo; ?In other words... You have a large application which
> > > > is most likely to be faster? :)
> > > >
> > > >
> > > I would assume your 2 examples to be the same because the point is that
> > > the PHP interpreter must parse for vars to substitute when it encounters
> > > double-quotes whether there are any vars in it or not. With
> > > single-quotes the interpreter does not have to worry about it.
> > > Regardless, the speed diff is probably negligible, hence my flame
> > > inviting post. :-)
> > >
>
> ehh my answer is meant to be here:
It's still wrong >:)
>
> nope. it parses both, since you may have escaped characters within
> > single quotes too. so the difference only comes in when you actually
> > have a variable in the string.
>
> sorry its morning ;)
Aaah, that's why you're confused :P
;)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP