Solved

Character sets

Posted on 2000-03-01
5
303 Views
Last Modified: 2013-12-03
I am using PHP4 as module on Apache 1.3.9 on RedHat Linux.
I have the following problem. Allmost all pages on this server are
in ISO-8859-2 character set. I have in HTML files the following
line in head section.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">

The HTML files served switch to the right character set in Netscape.

I use exactly the same syntax in my PHP files but those files are served
as ISO-8859-1 character set files regardless what I write in Content-Type.

I have found the solution in which I have to put the follwing code in
the begining of every PHP file:

<?
header ("Content-type: text/html; charset=iso-8859-2");
?>

I don't like this solution because I have to put the code in the begining
of every file.

How can I convince PHP to acknowledge meta tags in PHP files? Is
it possible that Netscape is doing this things wrong and PHP makes
things right.
0
Comment
Question by:marko020397
5 Comments
 

Expert Comment

by:npappas
ID: 2572674
I do something similar for Japanese character sets -- I use the header() call for each page, personally liking that method more.

What I actually have is a file I include on each page.  The top of all of my pages are the same, so I have a large block of HTML and the header() call in an external file.
I then just have to include it:
     <? include("lib/header.html") ?>
which handles everything.  This, of course, has to be at the very top since it involves the header() call.

You should be able to ditch the META call at that point.  You still have to include the PHP string on each page, but you don't have to include the META line on each page anymore.

That's my suggestion.
0
 
LVL 1

Expert Comment

by:sereda
ID: 2573447
Perhaps netscape sees that file has php extension and ignores meta tag, for whatever reason?
Try to assign your php file an html extension and see what happens.
0
 
LVL 2

Accepted Solution

by:
gravity earned 200 total points
ID: 2574173
Create a file that just has the following in it :

<?
header ("Content-type: text/html; charset=iso-8859-2");
?>

Call it what you like and stick it where you like.
Next, go to your php.ini file (usually in /usr/local/lib in Linux) and find the line with the entry "auto_prepend_file      =".
Now, say that the file you've created is located at /www/header.inc you should set it to look like "auto_prepend_file      = /www/header.inc"

This will include the header in every PHP script there is.

Just one word of warning - don't have *any* white space (i.e. " "'s) before or after the <? ?> tags or else you won't be able to use any other header() functions in your scripts.
0
 
LVL 4

Author Comment

by:marko020397
ID: 2575515
Thanks. It works.
0
 
LVL 2

Expert Comment

by:gravity
ID: 2576989
Groovy. As far as I remember, if you're running a lot of sites from one apache server and you have built PHP in either as a module or into Apache, you can specify the same function (ie auto_prepend_file) in the httpd.conf file.
However, this time it is named php_auto_prepend_file .

This is a really usefull feature and you can come up with some groovy helpers for sites. For example, including a header and footer in every file on your site just to give it that 'special look' could take quite a lot of time. Instead you can use the method above.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question