当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Error with accents in Portuguese on a html page

问题描述:

I have a big problem with the accent in Portuguese on my little site.

a Html page, which has the following fields:

Name input type="text";

Date of departure input type="text" with a Dojo calendar;

Cancel Phone Number: Yes / No input type="radio";

Cancel the data plate: Yes / No input type="radio";

Other: textarea.

I get the values ​​of all fields in PHP, the data displayed in the php file are correct when echo is performed. the problem is when I create a file.txt, has also experienced a .html file but it does not convert the accents.

So when I send the file in a powershell script, when the email is received appears without accents, more properly the letters with accents not appear, see question marks (?)

--> my php variables <--

$ name = $ _POST ['name'];

$ date = $ _POST ['fromDate_out'];

$ tele = $ _POST ['phone'];

$ board = $ _POST ['board'];

$ other = $ _POST ['other'];

$ OriginalDate = $ date;

$ Newdate = date ("d-m-Y", strtotime ($ OriginalDate));

--> creating the file im .txt and .html <--

$ fp = fopen (" SaidaColaborador . html", "w +");

$ write = fwrite ($ fp, "

< ! DOCTYPE html >

< html >

< body >

< head >

</ head>

Name: ------------------------------------- $ name

< br > Date: --------------------------------- $ Newdate

< br > Cancel number: - $ tele

< br > Cancel data plate: -------------- $ plate

< br > Other: -------------------------------- $ other

< / body >

< / html >

" ) ;

fclose ( $ fp );

/ *

$ fp = fopen ( " SaidaColaborador . txt " , " w + " );

$ write = fwrite ($ fp, "

Name: ------------------------------------- $ name

<br> Date: --------------------------------- $ Newdate

<br>Cancel number: -- $ tele

<br>Cancel data plate: -------------- $ plate

<br> Other: -------------------------------- $ other

");

fclose ($ fp);

* /

--> at last my powershell script <--

$ smtpServer = "my server"

$ smtpTo = "receiver"

$ smtpTo2 = "receiver2"

$ smtpTo3 = "receiver3"

$ smtpFrom = "sender"

$ messageSubject = "Saida_Colaborador"

$ body = "<b> </b> <br>"

$ file = 'C:\xampp\htdocs\SaidaColaboradorBCK03\FormColaboradorSaida\SaidaColaborador.html or .txt'

$ body + = Get - Content $ file

send-MailMessage -SmtpServer $ smtpServer -To $ smtpTo3 -From $ smtpFrom -Subject

$ messageSubject -Body $ body -BodyAsHtml -Priority high

--> and i expect to do something like this <--

Nome : Diogo á é í ó ú â ê î ô û õ ã ç

Data : 01-05-2014

Cancelar número de telefone : Não

Cancelar placa de dados : Não

Outros : olá, á, pé, mão

网友答案:

You need to set the encoding using the utf8_encode function, check http://www.php.net/manual/en/function.utf8-encode.php

分享给朋友:
您可能感兴趣的文章:
随机阅读: