Avatar of Poormandm
Poormandm
 asked on

str_replace unicode Error

I try to convert string  to unicode but I can't save the script because the server doesn't run the code. The server display the whole script.

Please copy the text below into notepad or any text editor and save as something.php and please remember to pick the encoding option to be Unicode.


<?php

$a = "a` a('";
$a = str_replace(array("a`", "a('"), array("à ", "&#7855; "), $a);
echo $a;
?>
PHP

Avatar of undefined
Last Comment
Richard Quadling

8/22/2022 - Mon
hernst42

If you see the source of the file, then your webserver is not configured to execute php-scripts correctly. As long as the "<?php" is not encoded in unicode and your webserver is configured correctly you will not see the code of your script.
Poormandm

ASKER
thanks
Poormandm

ASKER
let me try to build the include file and include that file in to see if php server can understand it.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Richard Quadling

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Poormandm

ASKER

the à  is unicode
http://www.unicode.org/charts/

à á &#7845; &#417; &#7901; &#432; &#273;
Poormandm

ASKER
experts-exchange.com change my unicode  to some strange numbers

the  &#7845 is actually the letter a( but the ( is on the top of the a.

That give me a hint, I should convert my unicode to ascii then use it.

Oh yes..

thanks
Poormandm

ASKER

transfrom

a á à &#7841; &#7843; ã
&#259; &#7855; &#7857; &#7863; &#7859; &#7861;
â &#7845; &#7847; &#7853; &#7849; &#7851;
e é è &#7865; &#7867; &#7869;
ê &#7871; &#7873; &#7879; &#7875; &#7877;
u ú ù &#7909; &#7911; &#361;
&#432; &#7913; &#7915; &#7921; &#7917; &#7919;
i  í ì &#7883; &#7881; &#297;
o ó ò &#7885; &#7887; õ
&#417; &#7899; &#7901; &#7907; &#7903; &#7905;
ô &#7889; &#7891; &#7897; &#7893; &#7895;
&#273;

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Richard Quadling

Hey! Glad to have helped. (Did I?).

What happens if you encode both pages as UTF-8? That SHOULD work better.