php-general Digest 2 Aug 2008 08:15:45 -0000 Issue 5602
Topics (messages 277594 through 277605):
Re: Internationalisation and MB strings
277594 by: Andrew Ballard
277595 by: Boyd, Todd M.
Re: Back to Basics - Why Use Single Quotes?
277596 by: Eric Butera
277597 by: Robert Cummings
277601 by: tedd
remembering where the user is on the page??
277598 by: Rod Clay
277599 by: Jim Lucas
277600 by: Per Jessen
277602 by: tedd
Exposing PHP/errors on production vs. dev
277603 by: mike
277604 by: Robert Cummings
277605 by: Richard Heyes
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Fri, Aug 1, 2008 at 2:30 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2008-08-01 at 13:24 -0400, Andrew Ballard wrote:
>> On Fri, Aug 1, 2008 at 12:34 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
>> > On Fri, 2008-08-01 at 11:12 -0500, Boyd, Todd M. wrote:
>> >> > -----Original Message-----
>> >> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yeti
>> >> > Sent: Friday, August 01, 2008 10:58 AM
>> >> > To: Andrew Ballard
>> >> > Cc: PHP General list
>> >> > Subject: Re: [PHP] Internationalisation and MB strings
>> >> >
>> >> > Oh right. Doing 1 measurement only is not even worth a theory.
>> >> >
>> >> > Well, I'm wondering how much PHP can speed that result up, since we are
>> >> > calling the same function with the same parameter 10000 times. Wouldn't
>> >> > it
>> >> > be even more realistic if we called it with changing strings?
>> >>
>> >> ---8<--- snip
>> >>
>> >> > > I ran this script several times, and the results below are fairly
>> >> > typical:
>> >> > >
>> >> > > MB_STRLEN took : 0.054733037948608 milliseconds
>> >> > >
>> >> > > STRLEN took : 0.037568092346191 milliseconds
>> >
>> > How did you measure these? I don't recall a time function that returns
>> > milliseconds... only functions that return seconds (and parts thereof in
>> > microseconds)... such as microtime().
>> >
>> > Cheers,
>> > Rob.
>>
>> If microtime(true) returns fractional seconds, wouldn't multiplying
>> the result by 1000 (as he did) convert the units from seconds to
>> milliseconds?
>>
>> 1 second = 1000 milliseconds = 1000000 microseconds, thus 0.000037568
>> seconds = 0.037568 milliseconds, correct? Am I missing something?
>
> I didn't see the multiplication by 1000 and the above numbers don't show
> any trailing zeros or truncation of precision as I would expect if the
> number had been multiplied by 1000. Although, maybe the multiplication
> occurred before the division by the number of runs. It just looked
> suspect to me.
>
> Cheers,
> Rob.
I've had moments like that. (One just yesterday in fact. :-) )
I did subsequently notice with the OP's code you will occasionally get
a negative number, too. Apparently the code enters some sort of
space/time continuum and sometimes manages to go back in time a few
microseconds. (Actually, there is a much more rational explanation for
it if anyone cares, but this one sounds cooler.)
Andrew
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Andrew Ballard [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 01, 2008 2:06 PM
> To: PHP General list
> Subject: Re: [PHP] Internationalisation and MB strings
---8<---
> > I didn't see the multiplication by 1000 and the above numbers don't
> show
> > any trailing zeros or truncation of precision as I would expect if
> the
> > number had been multiplied by 1000. Although, maybe the
> multiplication
> > occurred before the division by the number of runs. It just looked
> > suspect to me.
> >
> > Cheers,
> > Rob.
>
> I've had moments like that. (One just yesterday in fact. :-) )
>
> I did subsequently notice with the OP's code you will occasionally get
> a negative number, too. Apparently the code enters some sort of
> space/time continuum and sometimes manages to go back in time a few
> microseconds. (Actually, there is a much more rational explanation for
> it if anyone cares, but this one sounds cooler.)
I'm guessing that would be right around the time the PHP interpreter reaches 88
miles per hour and the flux capacitor is activated. :D
Todd Boyd
Web Programmer
--- End Message ---
--- Begin Message ---
On Fri, Aug 1, 2008 at 4:18 AM, Peter Ford <[EMAIL PROTECTED]> wrote:
>
> Now *that's* a good reason... anything that means fewer \'s or \"s.
> I often go for HEREDOC syntax if the backslashes start taking over -
> readability is much more important to me than nanoseconds of performance.
>
> There's also the case where you might want literal $s in your string:
> e.g.
> $foo = 'You need to pay $dollars...';
>
> compared with
>
> $foo = "You need to pay \$dollars...";
>
> Again, it depends on you view of backslashes.
>
>
> --
> Peter Ford phone: 01580 893333
> Developer fax: 01580 893399
> Justcroft International Ltd., Staplehurst, Kent
You know, I'd use HEREDOC if I could have the closing line indented.
I always think it looks so goofy to have it on the first of a line
inside a method in a class. When things get really weird I tend to
use (s)printf.
--- End Message ---
--- Begin Message ---
On Fri, 2008-08-01 at 15:36 -0400, Eric Butera wrote:
> On Fri, Aug 1, 2008 at 4:18 AM, Peter Ford <[EMAIL PROTECTED]> wrote:
> >
> > Now *that's* a good reason... anything that means fewer \'s or \"s.
> > I often go for HEREDOC syntax if the backslashes start taking over -
> > readability is much more important to me than nanoseconds of performance.
> >
> > There's also the case where you might want literal $s in your string:
> > e.g.
> > $foo = 'You need to pay $dollars...';
> >
> > compared with
> >
> > $foo = "You need to pay \$dollars...";
> >
> > Again, it depends on you view of backslashes.
>
>
> You know, I'd use HEREDOC if I could have the closing line indented.
> I always think it looks so goofy to have it on the first of a line
> inside a method in a class. When things get really weird I tend to
> use (s)printf.
*lol* Yeah, I hate how HEREDOC ruins my nice formatting too.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
At 3:41 PM -0400 8/1/08, Robert Cummings wrote:
*lol* Yeah, I hate how HEREDOC ruins my nice formatting too.
Cheers,
Rob.
Yeah, me too.
I just slam everything full-left and then I know it's a HEREDOC.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
I'm creating a website in php and I've noticed that many websites seem
to "remember where the user is on the page," so that, for example, the
user can click on a link and go to another page, but, when the user
comes back to the original page, it is displayed so that the user is
looking at the same part of the page that s/he was looking at when s/he
clicked the link. This is a mystery to me! How do you create a webpage
so that it "remembers" where the user is on the page and takes her/him
back to that same place on the page when the user returns? There must
be some "trick" to making this happen because a lot of pages do it and a
lot don't (like mine! :-( ). But I'd like to make mine do it too!!
Thanks for any light you can shed for me on this "mystery."
--- End Message ---
--- Begin Message ---
Rod Clay wrote:
I'm creating a website in php and I've noticed that many websites seem
to "remember where the user is on the page," so that, for example, the
user can click on a link and go to another page, but, when the user
comes back to the original page, it is displayed so that the user is
looking at the same part of the page that s/he was looking at when s/he
clicked the link. This is a mystery to me! How do you create a webpage
so that it "remembers" where the user is on the page and takes her/him
back to that same place on the page when the user returns? There must
be some "trick" to making this happen because a lot of pages do it and a
lot don't (like mine! :-( ). But I'd like to make mine do it too!!
Thanks for any light you can shed for me on this "mystery."
You are probably referring to <a name=""></a> tag placement.
If in your web page you place an anchor tag like this:
<a name="SomeName"></a>
Then in the URL you add this to the end #SomeName it will try and place that
position at the top of your viewable area in your web browser.
http://example.com/myfunpage.html#SomeName
If the page is really long this works just fine most of the time.
Hope this is what you are looking for... :)
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Rod Clay wrote:
> I'm creating a website in php and I've noticed that many websites seem
> to "remember where the user is on the page," so that, for example, the
> user can click on a link and go to another page, but, when the user
> comes back to the original page, it is displayed so that the user is
> looking at the same part of the page that s/he was looking at when
> s/he clicked the link. This is a mystery to me! How do you create a
> webpage so that it "remembers" where the user is on the page and takes
> her/him back to that same place on the page when the user returns?
Look up the "anchor" part of the URL.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
At 4:24 PM -0400 8/1/08, Rod Clay wrote:
I'm creating a website in php and I've noticed that many websites
seem to "remember where the user is on the page," so that, for
example, the user can click on a link and go to another page, but,
when the user comes back to the original page, it is displayed so
that the user is looking at the same part of the page that s/he was
looking at when s/he clicked the link. This is a mystery to me!
How do you create a webpage so that it "remembers" where the user is
on the page and takes her/him back to that same place on the page
when the user returns? There must be some "trick" to making this
happen because a lot of pages do it and a lot don't (like mine! :-(
). But I'd like to make mine do it too!!
Thanks for any light you can shed for me on this "mystery."
I had a similar problem.
I had a page where the user could edit the page. When the user was in
edit mode, the page was at one spot and when the user turned off
editing, I wanted the user to be back at where he was before editing.
I solved the problem by using javascript and recording the page's
position and then forcing the page to scroll there afterwards.
In any case this all client-side.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Does this look right?
Obviously you still want to know about production errors, so I'd like
to log them.
Development I want to see -everything- and I want it to display on the
page. The assumption is production won't have any notices as the code
should be clean and our higher priority are fixing errors. But that
one is easily editable if needed :)
Production:
display_errors = Off
display_startup_errors = Off
error_reporting = E_ALL & ~E_NOTICE
expose_php = Off
log_errors = On
error_log = syslog
Dev:
display_errors = On
display_startup_errors = On
error_reporting = E_ALL
expose_php = On
log_errors = On
error_log = syslog
Am I missing any?
--- End Message ---
--- Begin Message ---
On Fri, 2008-08-01 at 17:30 -0700, mike wrote:
> Does this look right?
>
> Obviously you still want to know about production errors, so I'd like
> to log them.
>
> Development I want to see -everything- and I want it to display on the
> page. The assumption is production won't have any notices as the code
> should be clean and our higher priority are fixing errors. But that
> one is easily editable if needed :)
>
> Production:
>
> display_errors = Off
> display_startup_errors = Off
> error_reporting = E_ALL & ~E_NOTICE
> expose_php = Off
> log_errors = On
> error_log = syslog
>
> Dev:
>
> display_errors = On
> display_startup_errors = On
> error_reporting = E_ALL
> expose_php = On
> log_errors = On
> error_log = syslog
>
> Am I missing any?
Personally, and I know I'm not alone here... I keep E_NOTICE enabled
in production also.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
> Personally, and I know I'm not alone here... I keep E_NOTICE enabled
Then you're both mad. Users really shouldn't see any error regardless,
so error reporting IMO should be off entirely. A blank screen that you
can blame on a variety of things is far preferable to users knowing
that your website is broken. In production I keep error_reporting set
to 0. There are a variety of things you could also do like log them to
a file or have them emailed to you so that you get notified when
errors occur.
--
Richard Heyes
http://www.phpguru.org
--- End Message ---