Solved

Character sets

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

635 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