Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
PHP special characters replace option
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Heaplink" data-source="post: 457248" data-attributes="member: 8966"><p>The problem is likely that your server, that serves the PHP files, does so with the wrong encoding. You can see this in browser DevTools (Chrome, Firefox, Edge, etc.) under the <strong>Network</strong> tab. If you click on the item that is the page itself, you can see the headers that are sent from the server:</p><p></p><p>[ATTACH=full]10166[/ATTACH]</p><p></p><p>Open DevTools (F12):</p><p></p><ol> <li data-xf-list-type="ol">Click on the <strong>Network</strong> tab.</li> <li data-xf-list-type="ol">Click on <strong>Doc</strong> in the filter list.</li> <li data-xf-list-type="ol">Click on the page that corresponds with the current page (see the URL, for example)</li> <li data-xf-list-type="ol">Find the <strong>Content-Type</strong> field and make sure it is [ICODE]text/html; charset=utf-8[/ICODE].</li> </ol><p>If this doesn't work there are two ways to fix it. The simplest way, but not the best as it requires you to do this for all pages, is to put the following line in top of every PHP script:</p><p></p><p>[CODE=php]header('Content-Type: text/html; charset=utf-8');[/CODE]</p><p></p><p>This should be put before outputting any content (echo, print, HTML, etc.).</p><p></p><p>A better way that will solve this problem across all scripts is to change your the configuration of PHP. You can find the location of the [ICODE]php.ini[/ICODE] file by creating a PHP file with the code:</p><p></p><p>[CODE=php]<?php phpinfo(); ?>[/CODE]</p><p></p><p>This will output info about your PHP instance. Look for "Loaded Configuration File". Open the file at that location, and find the setting [ICODE]default_encoding[/ICODE]—the setting may be commented out with a semi-colon. Just replace the whole line with the following:</p><p></p><p>[CODE=ini]default_charset = "utf-8"[/CODE]</p><p></p><p>Restart your web server and see if it works. With this configuration you wont need any settings or send headers, like the first way, as it automatically sets the correct encoding.</p></blockquote><p></p>
[QUOTE="Heaplink, post: 457248, member: 8966"] The problem is likely that your server, that serves the PHP files, does so with the wrong encoding. You can see this in browser DevTools (Chrome, Firefox, Edge, etc.) under the [B]Network[/B] tab. If you click on the item that is the page itself, you can see the headers that are sent from the server: [ATTACH=full]10166[/ATTACH] Open DevTools (F12): [LIST=1] [*]Click on the [B]Network[/B] tab. [*]Click on [B]Doc[/B] in the filter list. [*]Click on the page that corresponds with the current page (see the URL, for example) [*]Find the [B]Content-Type[/B] field and make sure it is [ICODE]text/html; charset=utf-8[/ICODE]. [/LIST] If this doesn't work there are two ways to fix it. The simplest way, but not the best as it requires you to do this for all pages, is to put the following line in top of every PHP script: [CODE=php]header('Content-Type: text/html; charset=utf-8');[/CODE] This should be put before outputting any content (echo, print, HTML, etc.). A better way that will solve this problem across all scripts is to change your the configuration of PHP. You can find the location of the [ICODE]php.ini[/ICODE] file by creating a PHP file with the code: [CODE=php]<?php phpinfo(); ?>[/CODE] This will output info about your PHP instance. Look for "Loaded Configuration File". Open the file at that location, and find the setting [ICODE]default_encoding[/ICODE]—the setting may be commented out with a semi-colon. Just replace the whole line with the following: [CODE=ini]default_charset = "utf-8"[/CODE] Restart your web server and see if it works. With this configuration you wont need any settings or send headers, like the first way, as it automatically sets the correct encoding. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
PHP special characters replace option
Top