I'm having some problems with accentuation and special characters on my website.
The problem only occurs on my webhosting (I've another website on the same hosting account, this one with the issue is in a sub folder, and the main website works well), on local with Wamp Server everything is OK.
So, my problem is: with .php extension accents aren't showed correctly but if I only change the file extension from .php to .html every accents are OK.
Edit:
I found my problem... I changed my code editor from notepad++ to sublime text and now it works.
It's strange because it was working well with wamp and in a free webhosting but not on my main hebhosting :/
Anyway, thank you very much for your help.
header('Content-type: text/html; charset=utf-8');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Note that, depending on where the text comes from, you might have to check some other things too (database-connection, source-file-encoding, ...) - i've listed a lot of them in one of my answers to a similar question.
In accordance with the similar issue
Charset=utf8 not working in my PHP page
you need to use ASCII character
And is your content type correctly set?
I searched for you: you can use this: é (ascii 130)
Related
Good day,
My dev pc env like this,
Win11 and NetBeans16 installed. I am dev PHP Lang now.
When I opened an existing source code folder and I found these Chinese content can't display normally.( Pls see screen capture posted as below)
I already tried several methods as below,
I configured the NetBeans Project Encoding to UTF-8; // doesn't work
I tried to type simple Chinese content in the IDE directly; // Same issue
I googled and modified the 'netbeans.conf' file and added the
-J-Dfile.encoding=UTF-8
at the end of netbeans_default_options=" , and then I restarted my NetBeans or enen I reboot my win OS. The problem is still can't resolve.
BTW,
I could view the Chinese content in Visula Studio Code via my PC.
And I configured my DB encode to UTF-8 Unicode (utf8mb4).
Thks for your suggestions in advance.
Followed Skomisa's suggestion. I solved the issue as below,
I must choose one font that support Chinese character and then I could render it in NetBeans edit window.(as I commented above)
See the result attached.
All my files with .php extension and Cyrillic encoding that worked fine for years got messed up. Probably because of PHP server upgrade by hosting provider.
To illustrate the problem I wrote the simplest possible file which cannot have any errors:
http://reverent.org/testencoding.php
For some reason webpage defaults to unicode when viewed in a browser. If you go to view -> Text encoding and select Cyrillic(Windows) everything gets fine.
In contrast, exactly the same file with .html extension is displayed correctly right away:
http://reverent.org/testencoding.html
Any idea?
Now, I'm no expert on this, but this seriously reminds me of the exact issue I had. So.. personal experience, here goes (I'm sure this might help someone):
My issue was that my files on the server were set to windows 1251 by default instead of UTF-8, which I needed.. this caused these little beasts to appear: � in place of every symbol that wasn't just a basic letter or something like that. Coincidentally this is what your example looks like. And the encoding is the same. I fixed it by accessing the files with WinSCP and just switching the files to UTF-8 manually... ironically your file shows pretty much what I saw on my website.
There must be better ways to do this than WinSCP, but to be honest, this is the only time I've had to do this manually, so this is exactly what I clicked there (after opening the file):
You could also try to fix it with a meta tag to tell the browser which charset to use, but the files might be getting deformed the moment you save them, if their encoding is wrong.
<meta charset="utf-8">
This might not work for you, but it did work for me, so there's hope :)
Hope it helps or at least points you in the right direction :)
I just put the php.ini file with this single line 'default_charset = "windows-1251"' in the directory with the files with Cyrillic encoding. This overwrites server's php.ini which sets default charset to UTF.
Now everything is fine: http://reverent.org/ru/testencoding.php
I've already tried the advice given on this page, by opening my .php page with Chrome, Mozilla, and IE (instead of dragging it to them), my EasyPHP is started (along with the other services I just installed with it), my files are located in C:\inetpub\wwwroot (on Vista), and so far, no PHP is being outputted. It either shows up as code on the page, or it doesn't work at all (includes don't work, for example). I tried configuring the DirectoryRoot in the httpd.config file (I commented out the original first, instead of deleting it), so it would point to the wwwroot directory, but that didn't work either. I am very new to EasyPHP and it's been a few years since I really dealt with regular PHP, Apache, and MySQL, so I'm grasping at straws here.
The code in my .htm file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>
<title>MySite</title><link href="MySite.css" rel="stylesheet" type="text/css"></head>
<body>
<?php
include("topbar.php");
?>
<div id="content">
<h2>Content Goes Here</h2>
</div>
</body>
</html>
The code in my topbar.php file:
<?php
echo '<div id="container"><div id="header">';
echo '<h1>This is the header.</h1><p class="description">';
echo 'Usually some sort of tagline or description is placed here.</p></div>';
?>
I don't know. I've been searching all over the PHP main site, as well as a few random pages that came up when I used my search engine... I've gone through the EasyPHP FAQ page, and I haven't yet found an answer the would point me in the right direction. Other than attempting to edit the httpd.config file, I haven't gone through any other files created by EasyPHP, mainly because I wouldn't know which ones to try editing, nor which lines, or with what. I just installed EasyPHP last night. I'm glad for any assistance anyone can provide in plain English (please, no one try to show off how cool you are with all your fancy technobabble that I'd have to get out a tech dictionary for, or lengthy examples that would be hard for a newb to read, thanks).
Web server will not process PHP code written in file extension other than .php. Try changing file extension to .php instead of .html.
You can use HTML tags within .php file.
I run a XAMPP Apache PHP Server on my Mac and I am facing the following problem: German special characters like ä ö ü and ß are displayed with strange questiontags instead of the correct symbol. I assume a misconfiguration of the server, since the files are all saved in UTF-8 and contain
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
In the -Tag of the files.
Anyone an idea how to get rid of those � ? I thought already of the httpd.conf , but there is already something like
#UTF 8
AddDefaultCharset utf-8
in it. The php.ini also includes
default_charset = "utf-8“
I really dont know how to proceed and my whole page looks not as nice as it should with those strange question tags...
Thanks for your Help!
Tim
I was having the same problem on my XAMPP local server and none of those things worked for me. The problem was in the transfer of data between mySQL (where all my foreign language looked good) and the server (where everything seemed good too). I was just missing this one statement in my.ini
"character_set_server=utf8"
which seems to affect data communication beetween server and mySQL
DON't change any other UTF-8 statements at the same time!
I run into the same problem after updating XAMPP.
I am using an other charset to display all kinds of characters used in countries like Holland, Germany, Norway, Sweden en Denmark. So my HTML contains:
Changing the default-charset into "windows-1252" did the trick for me.
Did you type these characters inside the source file? In this case, which encoding was the source file saved in?
With that meta tag "Content-Type" you are telling the browser to interpret the page as UTF-8 (despite whatever other value the server is returning). However, if you are saving the file in a different encoding that UTF-8, then it is displayed in the wrong way.
My suggestion is to check with your editor which encoding it is using, and tell it to use UTF-8 by default.
Open "my.ini" in "C:\xampp\mysql\bin\" directory.
Remove comment tag '#' from following code
init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
character_sets-dir="C:/xampp/mysql/share/charsets"
It's Work for me
The PHP file was in ANSI format. I changed it to UTF-8 and everything started working. I did not change any code.
I add to my.ini config file xampp and resolve
[mysqld]
character-set-server = utf8
delete this line in file mysql/bin/my.ini
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
or change utf8mb4 to uft8
character-set-server=utf8
collation-server=utf8_general_ci
IIS is literally sending <?php ... ?> code to the browser rather then executing it.
But, only for the root http://domain.com/index.php file.
All other .php files in that folder and index.php files in subfolders execute as expected.
How can I get my root index.php code to execute?
Update: "index.php" is a Default Document of my Web Site...
alt text http://img412.imageshack.us/img412/4130/defaultdocumentmt9.gif
It seems you have properly configured your handlers.
If you're using <? ... ?> make sure you have
short_open_tag = On
in your php.ini.
I was having this issue and ultimately tracked down the source to be the encoding of the PHP file. Apparently I had set my editor to use Unicode (2-byte unicode, not UTF-8) as the encoding. This causes PHP not to see the <? tags, but the browser seems to be able to read the Unicode file just fine, so viewing source reveals the actual PHP code. (Even though the file had a content-type=utf-8 meta tag!) Saving the PHP file in ANSI or UTF-8 encoding solved the problem.
Lots of debugging went into finding that simple solution, so I thought I'd add it here for anyone else who has this problem.
An interesting side-effect of the problem was that Firefox and Chrome didn't seem load the CSS file. Upon further examination, I found that browsers are supposed to assume the same encoding for CSS as for HTML, unless explicitly specified in the CSS file. Viewing the CSS in Chrome or Firefox would show Chinese characters! This helped lead me to the solution, actually.
IIS 5.1 does not run PHP properly under root directory, but fine in all other folders
Running a WordPress blog in site root using IIS
UPDATED: I have found a few possible workarounds for PHP 5 and IIS 7. If those solutions are not working, please provide more details about your index.php, IIS setup, or try to use IIS 6 compatibility.
Problem with PHP Includes on IIS7
PHP5 set-up - Relative paths for includes and other file references
Have you tried bouncing (stop/restart) IIS? Maybe even restarting the machine? I know there have been times when I've done some IIS configuration changes that I would have sworn should have only needed only a bounce to take effect that didn't get going until a full machine restart.
All though this is an old question, over 11 years later this is still an issue. My work around was to create default.aspx file and perform a redirect from within it. Save the file to the root directory of your website and add default.aspx to the default documents in IIS. Make sure you move it to the top of the list to prioritize it to be processed first. The below code is what I used.
<%# Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected override void OnLoad(EventArgs e) {
Response.Redirect("index.php");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Title Of Your Website Here</title>
</head>