character encoding - PHP how to display text from input tag correctly

371

when i echo something from an input (form in html) to php

the input value in html was:

强化课程

the echo (php) output was:

强化课程 

how to make it shows correctly?

I am using Php 5.3.10

85

Answer

Solution:

The page encoding should be set properly (if not done already) via the response headers:

header('Content-Type: text/html; charset=utf-8');
444

Answer

Solution:

In your HTML file make sure this meta tag is inside your<head></head> tag:

 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
498

Answer

Solution:

  1. make sure you set correct meta in html.

    <META http-equiv="Content-Type" content="text/html; charset=utf-8">

  2. set correct locale in php.

    setlocale(LC_ALL, "en_US.UTF-8");

People are also looking for solutions to the problem: php - Localized error pages in Symfony2

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.