Solved

Character sets

Posted on 2000-03-01
5
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 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