Solved

Character sets

Posted on 2000-03-01
5
287 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now