Date: 02/22/01
- Next message: Eric Hanson: "[phplib] repeated logins"
- Previous message: Paul Smith: "RE: [phplib] Template weirdness"
- In reply to: Stefano Baraldi: "[phplib] Can i install php 4.0.4 and use templates?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I am using templates with 4.0.4pl1 and 4.0.5. The only thing to watch
with 4.0.4 is that there is a problem with preg_replace if you want to
format a dollar value with a dollar sign. In both versions,
preg_replace uses $nn or \nn in the replacement string as placeholders
for backreferences.
So for example, suppose you are trying to set a variable in the template
for {VALUE} to $12345.00. The set_var will work, but when you parse the
template, preg_replace will treat the $12 as a backreference, which is
not defined, so you end up with {VALUE} being replaced by an $345.00.
This is a little annoying, 4.0.5 fixes the problem by implementing an
escape sequence for a litteral $ (\$ I think it was), however I can't
work out where the hell I got the source code for this, it was a CVS
snapshot but now I can't find the place I downloaded it from.
There are a couple of ways to fix this with 4.0.4. If you can live with
the look of it, simply place a space after the $ sign. Personally I
find this really ugly, so for my production system I just hacked up the
..../src/php-4.0.4/ext/pcre/php_pcre.c to remove the code that treats $
as a backreference and recompiled 8^), don't ya just love open source?
Just thought of something else, you can make the string something like
$<!-- -->12345.00, the browser should ignore the <!-- --> since it's a
comment and the preg_replace should work too... probably a bit nasty,
but quite effective, just hope that nobody goes looking at the HTML that
produces 8^P
Cheers
Michael Anthon
Stefano Baraldi wrote:
>
> Hi.
> Some time ago i saw messages about new versions of php breaking up the
> template class....
> Is this still true?
> Can i install php 4.0.4 without problems?
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Eric Hanson: "[phplib] repeated logins"
- Previous message: Paul Smith: "RE: [phplib] Template weirdness"
- In reply to: Stefano Baraldi: "[phplib] Can i install php 4.0.4 and use templates?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

