Sv: [phplib] Missing dollar signs after upgrade from php3 to php4 From: Klaus Seidenfaden (ks <email protected>)
Date: 05/11/01

-----Oprindelig meddelelse-----
Fra: Rob Hardowa <rob <email protected>>
Til: phplib <email protected> <phplib <email protected>>
Dato: 10. maj 2001 23:59
Emne: [phplib] Missing dollar signs after upgrade from php3 to php4

>Hi all,
>
>Can anyone help on this? It's been bugging me since January when our host
>upgraded from php3 to 4.
>(...)
>If I grab a field out of the database that contains something like $6.00 and
>parse the template, the resulting output is .00

I have this problem too. I insvestigated it and found that it happens in Template::subst(), when preg_replace() is called.

I then made this test script:

<html><body>
<?php
  $txt = 'Pay $6.00 or leave...';
  $str =  <email protected>('/x/', $txt, 'He said: "x", so I left.');
  print($str);
?>
</body></html>

and uploaded to my web hotel as preg.php3 *and* as preg.php4 to have them parsed by php version 3 and 4, respectively. In both cases, the output was:

He said: "Pay $6.00 or leave...", so I left.

but at home, with php4, it was:

He said: "Pay .00 or leave...", so I left.

So, looking closer at the version numbers of the two php4's, I found that my web hotel is running php4.0.3-dev, whereas I run php4.0.4pl1 at home.

Conclusion: It is a preg_*()-issue with php4, introduced after v4.0.3-dev.

A workaround might be to subclass Template and write your own subst(), escaping '$' characters before doing preg_replace().

-- Klaus.

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>