Re: PHP 4.0 Bug #5800: Several things with str_replace()
| From: | Derick Rethans | Date: | Wed, 26 Jul 2000 17:07:18 +0000 |
| Subject: | Re: PHP 4.0 Bug #5800: Several things with str_replace() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-26343@lists.php.net to get a copy of this message | ||
Yin.Yang@gmx.net wrote:
> From: Yin.Yang@gmx.net
> Operating system: Win NT 4.0 (ISAPI)
> PHP version: 4.0.1pl2
> PHP Bug Type: Scripting Engine problem
> Bug description: Several things with str_replace()
>
> $headlbody = str_replace("\n", "<br>", $headlbody);
> $headline1 = "<b>$headlhead</b><br>\n$headlbody<br>\n";
> $fp = fopen("D:\\newsadmin\\headline.txt", w);
> ....
> makes from "Word1\nWord2\nWord3"
> "Word1\n<br>Word2\n<br>Word3".
> (mail me for full script and result-file)
What's in $headlbody before you do: $headlbody = str_replace("\n",
"<br>", $headlbody); ?
>
>
> Due some replies in de.comp.lang.php I tested the following script with the following - amazing
> - results:
>
> <?
> echo
> "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>\n";
> $x = "Word1\nWord2\nWord3\n";
> echo nl2br($x);
> echo str_replace("\n", "<br>", $x);
> echo "<\n</BODY></HTML>\n";
> ?>
>
> <HTML><HEAD><TITLE></TITLE></HEAD><BODY>
> Word1<br>
> Word2<br>
> Word3<br>
> Word1<br>Word2<br>Word3<br>< //note the last char!
> </BODY></HTML>
This is not strange, in your last line you put echo "<\n" which prints that
"<" character.
--
Derick Rethans
JDI Media Solutions
H.v.Tussenbroekstraat 1
6952 BL Dieren
The Netherlands
e-mail: d.rethans@jdimedia.nl
http://www.jdimedia.nl/