views:

107

answers:

3

Hello I have two php file. One of them builds a report, the second contains the language text. When it prints, it keeps giving me the � special character everywhere, even if I am not using any special characters in my code. Why is that and how can I get rid of those?

I am running Apache 2.2, php 5, Ubuntu 8.04.

FILE 1

<?php
function glossary() {
return <<<HTML
    <h1>Arteries</h1>
    <p><strong>Arteries</strong> are blood vessels that carry blood <strong>away from 
the heart</strong>. All arteries, with the exception of the pulmonary and umbilical 
arteries, carry oxygenated blood.   The circulatory system is extremely important for 
sustaining life. Its proper functioning is responsible for the delivery of oxygen 
and nutrients to all cells, as well as the removal of carbon dioxide and waste products, 
maintenance of optimum pH, and the mobility of the elements, proteins and cells of 
the immune system. In developed countries, the two leading causes of death, myocardial 
infarction and stroke each may directly result from an arterial system that has been 
slowly and progressively compromised by years of deterioration.</p>
HTML;
}
?>

FILE 2:

<?php
require_once("language.php");

echo glossary();
?>


This is the printout when I execute file 2.

Glossary Arteries

Arteries�are�blood vessels�that carry blood�away from the�heart. All arteries, with the exception of the�pulmonary�and�umbilical arteries, carry oxygenated blood. The�circulatory system�is extremely important for sustaining�life. Its proper functioning is responsible for the delivery of�oxygen and�nutrients�to all cells, as well as the removal of�carbon dioxide�and waste products, maintenance of optimum�pH, and the mobility of the elements, proteins and cells of the�immune system. In�developed countries, the two leading causes of�death, myocardial infarction�and�stroke�each may directly result from an arterial system that has been slowly and progressively compromised by years of deterioration. Autoimmunity

Autoimmunity�is the failure of an organism to recognize its own constituent parts as�self, which allows an immune response against its own cells and tissues. Any disease that results from such an aberrant immune response is termed an�autoimmune disease.� Basal cell carcinoma

Basal cell carcinoma�is the most common type of�skin cancer. It rarely�metastasizes�or kills, but it is still considered�malignant because it can cause significant destruction and disfigurement�by invading surrounding tissues. Statistically, approximately 3 out of 10 Caucasians develop a basal cell cancer within their lifetime. In 80 percent of all cases, basal cell cancers are found on the head and neck.�There appears to be an increase in the incidence of basal cell cancer of the trunk in recent years.

+5  A: 

Try deleting and re-entering the spaces which show up as "�".

I suspect those you re-enter will be fine. The document likely contains alternate Unicode space characters which appear normally in your editor, but are unrecognized by the PHP code running in the default character set for your server.

Did this document originally come from MS Word or some other word processor?

ryandenki
+2  A: 

Have you checked your encoding? Make sure that you use the same encoding within the editor, apache, php and the browser you are using.

Hope this helps.

da8
+3  A: 

You need to make sure that you have your editor encoding set to something sensible such as UTF-8. You should also make sure that your output is set to UTF-8 (or whatever encoding is relevent to you). This can be done using a meta tag <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> and setting the PHP header header('Content-type: text/html; charset=UTF-8'); before your output begins.

Kieran Hall
Adding that meta tag would probably solve the display problem.Still, it would be best to replace the Unicode spaces in the original text.
ryandenki