Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Character sets

Posted on 2000-03-01
5
Medium Priority
?
317 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

721 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