php-general Digest 6 Mar 2011 06:04:05 -0000 Issue 7213

Topics (messages 311700 through 311709):

Re: Overriding session length in existing session?
        311700 by: Marc Guay
        311702 by: tedd

Is 5.3.5 really that much slower than 5.2?
        311701 by: Joel

Re: Regex for extracting quoted strings
        311703 by: Shawn McKenzie
        311704 by: Simon J Welsh
        311705 by: Mark Kelly
        311707 by: Shuo

Re: $GLOBALS example script on php.net
        311706 by: Ashim Kapoor

Re: error message for date()
        311708 by: Roger Riordan
        311709 by: Roger Riordan

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 ---
> The statement should be at the start of every php file that has php code in 
> it.

Hi Tedd,

Normally I'd agree with this but having never used the function
session_set_cookie_params() before, I looked it up, and the manual
says to put it before session_start().

"Set cookie parameters defined in the php.ini file. The effect of this
function only lasts for the duration of the script. Thus, you need to
call session_set_cookie_params() for every request and before
session_start() is called. "

Marc

--- End Message ---
--- Begin Message ---
At 1:29 PM -0500 3/5/11, Marc Guay wrote:
> The statement should be at the start of every php file that has php code in it.

Hi Tedd,

Normally I'd agree with this but having never used the function
session_set_cookie_params() before, I looked it up, and the manual
says to put it before session_start().

"Set cookie parameters defined in the php.ini file. The effect of this
function only lasts for the duration of the script. Thus, you need to
call session_set_cookie_params() for every request and before
session_start() is called. "

Marc


Marc:

Okay, but read on -- there seems to be debate on it.

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
Hi list,

I've been getting my code base ready to upgrade from 5.2 to 5.3 for
all the great features and supposed performance and memory
improvements, but with regular usage (ie. on my production servers) I
just don't see those improvements.

With 5.2 pages load on average of 2ms and consume between 256-512k of
memory at peak. The same pages under 5.3.5 take on average 4ms and
consume about 1.2mb of memory at peak. The only difference in the
config is that 5.3 is using mysqli with msqlnd, while the 5.2 is using
libmysql for mysqli. I understand that mysqlnd should make things
faster and use more memory (using PHP's native memory for storing
data), but these are on pages with no database connections at all.
They're pretty complicated pages with very little OO and with lots of
small pieces coming from file caches.

I'm guessing that 5.3 might be faster in heavy OO usage, but I can't
see how a big shop can simply upgrade from 5.2 to 5.3 without
performance being a big concern.

Those numbers might not appear big, but they make a huge difference
when serving thousands of requests/s.

Are there practical reasons why 5.3 is so much slower?
Is there a trick to making it behave better, or do I simply have to
stick with 5.2 until it's no longer supported?
Is anyone else out there in the same boat?

Thanks!

Joel

--- End Message ---
--- Begin Message ---
On 03/05/2011 09:26 AM, Mark Kelly wrote:
> Hi.
> 
> I'm hoping someone can help me extract text between double quotes from a 
> string.
> 
> $regex = 'some magic';
> $r = preg_match($regex, $sentence, $phrases);
> 
> So, if 
> 
> $sentence = 'Dave said "This is it". "Nope, that is the wrong colour" she 
> replied.';
> 
> I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'.
> 
> Can anyone help?
> 
> Cheers,
> 
> Mark

$regex = '/"([^"]+)"/';

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote:

> On 03/05/2011 09:26 AM, Mark Kelly wrote:
>> Hi.
>> 
>> I'm hoping someone can help me extract text between double quotes from a 
>> string.
>> 
>> $regex = 'some magic';
>> $r = preg_match($regex, $sentence, $phrases);
>> 
>> So, if 
>> 
>> $sentence = 'Dave said "This is it". "Nope, that is the wrong colour" she 
>> replied.';
>> 
>> I want $phrases to contain 'This is it' and 'Nope, that is the wrong colour'.
>> 
>> Can anyone help?
>> 
>> Cheers,
>> 
>> Mark
> 
> $regex = '/"([^"]+)"/';
> 
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com

Also, you'll want preg_match_all rather than preg_match.

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


--- End Message ---
--- Begin Message ---
Hi.

Thanks for all the replies.

On Saturday 05 Mar 2011 at 22:11 Simon J Welsh wrote:

> On 6/03/2011, at 11:08 AM, Shawn McKenzie wrote:
> > $regex = '/"([^"]+)"/';

Shawn, this regex gets me two copies of each string - one with and one without 
the double quotes - as did the one Nathan posted earlier.
 
> Also, you'll want preg_match_all rather than preg_match.

Yeah, I realised that quite early on in my messing about.

What I have ended up with is:

$regex = '/".*?"/';
$found = preg_match_all($regex, $sentence, $phrases);

This still leaves the quotes in the phrases, but at least I only get one copy 
of each phrase. I'm just trimming the quotes afterwards.

Thanks for all the advice.

Mark

--- End Message ---
--- Begin Message ---
Maybe this will help.

$regex = '/(?<=")[^.]*(?=")/';
$r = preg_match_all($regex, $sentence, $phrases);

--- End Message ---
--- Begin Message ---
Dear Ashley,

I do follow the part when it creates a local copy of $GLOBALS.

When it unsets them, is there a subtlety of unset that it ONLY unsets system
defined entries? Could you please explain this ?

Thank you,
Ashim

--- End Message ---
--- Begin Message ---
On Sat, 5 Mar 2011 20:42:07 +1300, [email protected] (Simon J Welsh) wrote:

>On 5/03/2011, at 8:29 PM, [email protected] wrote:
>
>> After a long battle to get my system back on air after a hard disk crash, I 
>> got PHP 5.3.5
>> running under Apache 2.2.3. I now get a diagnostic every time I call date(), 
>> complaining
>> about a missing parameter. The manual states that the second parameter is 
>> optional, and
>> even phpinfo doesn't know about this new requirement, as it contains the 
>> same diagnostic:
>> 
>> "Warning: phpinfo(): It is not safe to rely on the system's timezone 
>> settings. You are
>> *required* to use the date.timezone setting or the 
>> date_default_timezone_set() function.
>> In case you used any of those methods and you are still getting this 
>> warning, you most
>> likely misspelled the timezone identifier. We selected 'Australia/Melbourne' 
>> for
>> '11.0/DST' instead in D:\Websites\index.php on line 1 Warning: phpinfo(): It 
>> is not safe
>> to rely on the system's timezone settings. You are *required* to use the 
>> date.timezone
>> setting or the date_default_timezone_set() function. In case you used any of 
>> those methods
>> and you are still getting this warning, you most likely misspelled the 
>> timezone
>> identifier. We selected 'Australia/Melbourne' for '11.0/DST' instead in
>> D:\Websites\index.php on line 1 ".
>> 
>> Is this a bug, or a new requirement we will have to get used to?
>> 
>> 
>> 
>> Roger Riordan AM
>
>It's not complaining about a missing parameter, it's complaining about the 
>lack of a specified timezone.
>
>This warning was introduced in PHP5.1, and you either need to set the 
>date.timezone INI setting, either in your php.ini or by using ini_set(), or by 
>passing a valid timezone to date_default_timezone_set() before calling any 
>other date-related functions.
>---
>Simon Welsh
>Admin of http://simon.geek.nz/
>
>Who said Microsoft never created a bug-free program? The blue screen never, 
>ever crashes!
>
>http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e

Thanks for this.  I have put date_default_timezone_set() at the start of my 
program, which
clears up all my bugs, but leaves the bug in PHP.ini. This doesn't worry me.

And now I know where my son found the "10 types of people" T-shirt. 
Unfortunately I seldom
wear T-shirts, and my friends wouldn't get the joke anyway.

With my best wishes,


--- End Message ---
--- Begin Message ---
PS. What is "date.sunrise_zenith"? I am surprised that PHP contains a function 
to return
the time of sunrise for a given location, but I thought that latitude, 
longitude, date and
time zone would be all you had to know.


--- End Message ---

Reply via email to