This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 2 years ago.
index.php
<?php
include("header.php");
?>
header.php
<?php
echo"<a href='add.php'>Lägg Till</a>";
?>
result
L?gg Till
The document is utf8 within the head tags and all, it's a php thing, the problem only occurs when i get text from include, i cannot have ÅÄÖ in included php files , how do i make it work?
Save these files in utf-8 too
when sending text to server with accents letters use always ut8_encode, in you case:
echo utf8_encode("<a href='add.php'>Lägg Till</a>");
I have the same problem and this on solves them.
Besides saving the file in UTF-8 you could also check the "default_charset" configuration in the php.ini file.
Related
This question already has answers here:
Is there anyway to have Notepad++ highlight both PHP and HTML at the same time?
(2 answers)
Closed 7 years ago.
<html>
This is file is called "example.php".<br>
<?php print "=== This is printed by a php 'print' statement<br>"; ?>
This text is after the embedded php.
</html>
When either of the html tags, its mate is found, and both are given a distinctive color.
But the php tags don't find their mates, and don't get highlighted. How can I get that behavior?
Save your file in .php extention in notepad ++.
If that does not sort the problem download the latest version of notepad++ from here.
Here : it works see :) -
Let me know if anyother issues :)
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 7 years ago.
I have the following function;
function generateFirstName(){
$firstNameArray = array("Thomáš ","Lukáš ");
$firstNameKey = mt_rand(0,1);
$firstName = $firstNameArray[$firstNameKey];
return $firstName;
}
When the function is called on the same page the UTF-8 format outputs fine, but when it is called from a functions.php (that is REQUIRED in the INCLUDED head.php) the UTF-8 format doesn-t arrive and i get the dreaded black diamond with white question mark.
What do I need to do to pass the strings?
Check every required or included files encoding. They all must be in UTF-8 to work together. You have to be sure about every file, that can be included from functions.php and other files.
Each file must be encoded in utf8
This question already has answers here:
Magic quotes in PHP
(12 answers)
Closed 8 years ago.
I am working on a website and I have a php editor that automatically adds \ to certain things. I was aware of the stripslashes() function and I know it can be used in a way such as: stripslashes($test) but I am including something and I do not know how to strip the slashes from the Page I am including. Here is my include code that I am using:
<?php include $_SERVER['DOCUMENT_ROOT']."/newseditor/BlogTitle.php"; ?>
So how would I stripslashes from this? Thanks for reading and I appreciate all help I recieve.
You are suffering from PHP's magic quotes, and here is how to turn it off:
http://www.php.net/manual/en/security.magicquotes.disabling.php
This question already has an answer here:
Encoding detecting php
(1 answer)
Closed 8 years ago.
I need help with encoding :(
I have parsed string from site: Ëè÷íûå âñòðå÷è
My site is in UTF-8 encoding.
How to convert parsed string to encoding of my site?
On this site artlebedev.ru/tools/decoder
When I click on "Расшифровать" button, I get right result: Личные встречи.
this does not work you say?
echo iconv("iso-8859-5","utf-8","Ëè÷íûå âñòðå÷è");
then are you sure your file is utf8 also?
try this
echo iconv("cp1251","utf8",iconv("utf8","cp1252","Ëè÷íûå âñòðå÷è"));
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Headers already sent by PHP
I have a single php file, with this code in it:
<?php header("Location: somepage.php"); ?>
Absolutely no spaces before or after the php opening or closing tags and I am getting the
Warning: Cannot modify header information - headers already sent by (output started at C:\ ... \test.php:1
Usually when I get this error, the 1 is the line number of the problem, but in this case line one doesn't have any extra whitespace. I only have this code on the page and I am not including any other files.
I'm using xampp on windows xp. Any ideas what's going on or how I can track down what's really causing the problem.
Thanks
Chances are that you have what's known as a BOM (Byte Order Mark) in the file. Depending on what editor you're using, you'll need to turn off adding the BOM...
Try to copy / paste your content to another new file using Notepad
Try using WAMP, it doesnt show this error, make sure you donot have spaces before or after the code. For that, if you are using notepad ++ or editplus, go to format and select unix formatting and things should work fine.
OR
try placing this at the top of your page:
<? ob_start(); ?>
then at the bottom of the page place this line of code:
<? ob_flush(); ?>
If you are sure it is not a BOM causing the error, check your httpd.conf and any .htaccess files if the prepend any other files. Look out for something like this:
<FilesMatch "\.(html?)$">
php_value auto_prepend_file /server/path/to/my/www_root/subdir/file.ext"
</FilesMatch>
Also check your PHP.ini: http://de.php.net/manual/en/ini.core.php#ini.auto-prepend-file