|
Posted by e_matthes on 05/30/07 01:30
On May 29, 3:32 pm, Alexey Kulentsov <criman...@crimaniak.com> wrote:
> e_matt...@hotmail.com wrote:
> > $acceptableTextRegExp = "/^[a-zA-Z0-9_\- ]\{$minLengthIn,
> > $maxLengthIn}/";
> .....
> > If I take out the \ before the open brace, both systems give me an
> > error about unmatched braces. Are escape characters handled
>
> PHP try to parse this: {$minLengthIn,$maxLengthIn} as one expression. {}
> used in PHP string as special symbols. You can use '-string to avoid
> such things:
>
> $acceptableTextRegExp = '/^[a-zA-Z0-9_\-
> ]{'.$minLengthIn.'.'.$maxLengthIn.'}/';
I can use the single-quote method to make my code work:
$regExp = '/^[a-zA-Z0-9_\- ]{' . "$minLength,$maxLength" . '}/';
I would still really like to know, however, why my local php
installation and the installation on my shared server interpret this
line differently:
$regExp = "/^[a-zA-Z0-9_\- ]\{$minLength,$maxLength}/";
My understanding is that the backslash tells php to escape the
following open brace. It seems to do that locally, but not on the
shared server. Any reason why the behavior is different on the two
systems?
Navigation:
[Reply to this message]
|