Jump to content


Photo

*SOLVED* phpincludes problem


  • Please log in to reply
4 replies to this topic

#1 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 10 May 2006 - 04:27 AM

Hey guys,

I already know how the PHPincludes function works. I am currently designing a website that uses chinese text, as a result I have to remember to use the charset of UTF-8 and this must be included in every page or else the text appear as "???"

So the problem is my phpincludes are just blocks of html code and they are not necessary from the header tag. In other words, I can't include the charset of UTF-8 in every phpinclude file.

For example say,

index.php file includes a test.php file.

The index.php has the:

<?php header('Content-Type: text/html; charset=utf-8'); ?>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

stuff, while the test.php has all the chinese text but none of the charset stuff. When I try to save test.php all the text will revert to ??? and so when I include it in the index.php it appears as ???

Can anyone help me?

I'm learning PHP and mySQL. Please forgive my ignorance :(

#2 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 10 May 2006 - 05:17 AM

This is easy, just use a text editor with multibytes encoded.
you can use the same editor that you write chinese code. Simply write php codes in it and save as php file.

I used M.S. Visual studio .NET, but there're million of editor out there you can find.
Life's too short for arguing.

#3 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 10 May 2006 - 06:49 AM

[!--quoteo(post=372828:date=May 9 2006, 09:17 PM:name=hvle)--][div class=\'quotetop\']QUOTE(hvle @ May 9 2006, 09:17 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This is easy, just use a text editor with multibytes encoded.
you can use the same editor that you write chinese code. Simply write php codes in it and save as php file.

I used M.S. Visual studio .NET, but there're million of editor out there you can find.
[/quote]

I don't really understand your solution. I use dreamweaver as my developing environment. When I save it simply says this:

"The document's current encoding can not correctly save all of the characters within the document. You may want to change to UTF-8 or an encoding that supports the special characters in this document."

I have to add the meta and php charset tag to prevent this from occuring.
I'm learning PHP and mySQL. Please forgive my ignorance :(

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 10 May 2006 - 11:04 AM

You might want to configure Dreamweaver to use the UTF-8 charset by defualt.

You can do this by opening Dreamweaver then if you go to Edit > Preferences > and now the preferences window appears select the option from the list that says New Document Now from the Defualt encoding pull down menu select UTF-8 charset.

#5 Heero

Heero
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 11 May 2006 - 01:16 AM

[!--quoteo(post=372882:date=May 10 2006, 03:04 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 10 2006, 03:04 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You might want to configure Dreamweaver to use the UTF-8 charset by defualt.

You can do this by opening Dreamweaver then if you go to Edit > Preferences > and now the preferences window appears select the option from the list that says New Document Now from the Defualt encoding pull down menu select UTF-8 charset.
[/quote]

That solved the problem. Thanks!

I'm learning PHP and mySQL. Please forgive my ignorance :(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users