2010-05-19 25 views
8

Tôi đang sử dụng PHP bao gồm để bao gồm tệp PHP có HTML trong đó. một số nội dung có dấu tiếng Pháp và những nội dung này hiển thị dưới dạng trên trang web. Làm thế nào điều này có thể được giải quyết?Bao gồm PHP và dấu trọng âm (Chúng hiển thị dưới dạng )

Cảm ơn

Dưới đây là file PHP tôi bao gồm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
<meta content="en-us" http-equiv="Content-Language" /> 
<title>Accueil</title> 
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
<meta content="Changement créativité rêve buts être centré Plénitude personnel                 Développement transformation Modification nouveauté avancement bien-être     Nouvelle vision ressentis L’énergie positive satisfaction l’acceptation Pardon" name="keywords" /> 
<link href="masterstyles.css" rel="stylesheet" type="text/css" /> 
<link href="menustyles.css" rel="stylesheet" type="text/css" /> 
<link href="menudropdown.css" rel="stylesheet" type="text/css" /> 

<td class="tbsyles" >&nbsp; 
     <h3 class="bigorange"> ACTIVITÉS À VENIR…</h3> 
     <p class="horizblue"> </p> 
     <p class="bigblack"> <br /> 
     Inscrivez-vous à nos conférences et formations 
     <br /> 
     <br /> 
     </p> 
     <h4 class="orange"> Example of some text that could be here<br /> 
     </h4> 
     <p class="horizblue"> &nbsp;</p> 
     <h3 class="bigorange"> <br /> 
     ABONNEZ-VOUS… </h3> 
     <p class="nopadding"> À notre liste d’envoi </p> 

    <form method="post" action="<?php echo $PHP_SELF;?>"> 
<?PHP 
function process_info(){ 

    if(isset($_POST['email'])) 
{ 

$email=$_POST["email"]; 
    $email=strtolower($email); 
    $action = "subc"; 

     // check if email exists 

     // check whether email is correct (basic checking) 
      $test1=strpos($email, "@");          //value must be >1 
      $test2=strpos(substr($email,strpos($email,"@")), ".");   //value must be >1 
      $test3=strlen($email);           //value must be >6 
      $test4=substr_count ($email,"@");        //value must be 1 

if ($test1<2 or $test2<2 or $test3<7 or $test4!=1) 
      { 

      print "<h6>Il a une erreur avec vôtre email</h6>"; 
      print "<h6>Aucune informations ont été envoyer</h6>"; 


      } 
      else 
      { 
      print "<h5>vôtre address est enregistrer, Merci </h5>"; 


       //If they wanted to subsribe, do it... 


      $file = "emaillist-666XXX.txt"; 

      // lets try to get the content of the file 
if (file_exists($file)){ 
     // If the file is already in the server, its content is pasted to variable $file_content 
     $file_content=file_get_contents($file); 
} 
else{ 
     // If the file does not exists, lets try to create it 
     // In case file can not be created (probably due to problems with directory permissions), 
     // the users is informed (the first user will be the webmaster, who must solve the problem). 
     $cf = fopen($file, "w") or die(""); 
     fclose($cf); 
} 

// IF REQUEST HAS BEEN TO SUBSCRIBE FROM MAILING LIST, ADD EMAIL TO THE FILE 
if ($action=="subc"){ 
     // check whether the email is already registered 
     if(strpos($file_content,"<$email>")>0){die("");} 
     // write the email to the list (append it to the file) 
     $cf = fopen($file, "a"); 
     fputs($cf, "\n$email");  // new email is written to the file in a new line 
     fclose($cf); 

} 
} 
} 
} 


process_info(); 


?> 


      &nbsp;<p class="nopadding">Votre Courriel</p> 
      <input name="email" type="text" class="style3" /> 
        <input name="Submit" type="submit" value="OK" /></form> 

       <p class="horizblue"></p> 
       <h3 class="bigorange"> <br /> 
       OUTILS GRATUIT… </h3> 
       <p class="nopadding">Amusez-vous avec des outils intéressants</p> 
     </td> 

Trả lời

9

Điều đó xảy ra nếu trình duyệt cho rằng bạn đang sử dụng mã hóa khác so với thực tế bạn sử dụng.

cố gắng thêm những điều sau đây trong tập tin php của bạn trước khi bất kỳ html được in:

header ('Content-type: text/html; charset=utf-8'); 
// or 
header ('Content-type: text/html; charset=iso8859-15'); 

và thêm

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<!-- or --> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-15" /> 

giữa <head></head> thẻ

CẬP NHẬT: chỉ cần nhìn thấy bạn cập nhật với tệp. bạn cần phải thêm header ('Content-type: text/html; charset=utf-8');

+0

Đó làm việc! cảm ơn –

0

charset của trang HTML là gì? Có vẻ như bộ ký tự của tệp PHP và HTML trong đó khác nhau. Bạn có thể muốn kiểm tra:

Để được trợ giúp thêm, vui lòng gửi một số mã, đặc biệt là loại tài liệu mà đang được đầu ra và bất kỳ cuộc gọi đến PHP charset chức năng.

0

Nếu việc chuyển đổi bộ ký tự không khắc phục được, bạn có thể sử dụng các thực thể. &eacute; cho é, &ocirc; cho ô và như vậy trên

P.S. 'Il một une erreur avec Votre email' -> Bạn nên nói 'Il y a', nó Votre không Votre và email có thể được dịch sang 'courriel' :)

+0

Cảm ơn, tôi không phải là người đã viết, tôi chỉ sao chép dán những gì đã được trao cho tôi – jmasterx

0

Hãy thử sử dụng

<meta http-equiv="Content-Language" content="fr"/> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
1

Tôi đã có cùng một vấn đề với một trang web cho một khách sạn Pháp.

Thay đổi bộ ký tự thành "ISO-8859-1" thay vì "UTF-8" đã thực hiện thủ thuật.

Ví dụ: < form method = "post" name = "liên hệ" action = "send_mail.php" chấp nhận-charset = "ISO-8859-1">

Các vấn đề liên quan