Page 1 of 1

quirky str_replace behaviour

Posted: Tue Jul 29, 2003 7:17 pm
by jmarcv
I've been doing PHP for about 3 years now, and this one is a headscratcher.
My site tracks classified ads, and the copy is in a db. I compose it for a screen using html tags, then convert those to xtag format to import into Quark.

Most quark xtags are similar to html, ie:
<B></B> in quark is <B><B>
so, I simply do:

$quark =str_replace('</','<',$html);

My client has Macs. They use OSX with the standard php/mysql implementation. It is php4.
All users use IE5
Now, on one pesky machine, the replacement doesn't happen, or if it does, it gets reverted back.

Has anyone seen anything like this? It doesn't make sense. PHP is server side scripting, so how the heck can one client machine be different?

...

Posted: Wed Jul 30, 2003 1:01 am
by kettle_drum
Are you storing it in the database as / or as an ascii code?

See what happens if you try to escape it with \.

if this doesnt work then see what results you get with ereg_replace().

Posted: Wed Jul 30, 2003 8:52 am
by jmarcv
Actually, the data is being written on the fly to a variable, and then output to a file. I started with ereg_replace, escaping the slash, but when that screwed up I went to str_replace to avoid the escaping issue and use straight text replacing.

But, again, I don't think code is the issue. I've done this a million times. It is ONE computer that does it. I have 2 macs side by side, one works as I expect it to, and as the PHP Manual explains it to happen, the other either does not do the replacement (which flies in the face of server side logic) or reconverts.
Just wondering if anyone else has seen this quirkiness elsewhere.

The more I deal with Macs, the more I scratch my head.