quirky str_replace behaviour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

quirky str_replace behaviour

Post 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?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

...

Post 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().
jmarcv
Forum Contributor
Posts: 131
Joined: Tue Jul 29, 2003 7:17 pm
Location: Colorado

Post 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.
Post Reply