Jump to content

Apache+php


spider

Recommended Posts

Hi y'all! I've recently installed Apache server 2.2, PHP 5.2x. Apache installed alright (It works! in the browser window), PHP too (127.0.0.1 returned the PHP intro page with descriptions and everything). I tried to test them and introduced a simple line into an html code,<html><head><title>PHPTest</title></head><body><?php $salutation = "Hello, World!"; echo "<p> $salutation </p>";?></body></html>and opened the file (test.php) in my browser. But it returned the following textЗдравствуй, мир!Anyone any idea? Thanks in advance!

Link to comment
Share on other sites

I mean if you open the PHP page in the browser, and then go to View->Source, what's there?
The source breaks down like this<html><head><title>Страница сценария с переменной</title></head><body><p> Здравствуй, мир! </p></body></html>
Link to comment
Share on other sites

Yeah, that's weird. Would there be some sort of output module for Apache which is rewriting the pages? It transforms the title text and the paragraph text but doesn't do anything to the HTML tags - that sounds like a program being run on the output.

Link to comment
Share on other sites

Yeah, that's weird. Would there be some sort of output module for Apache which is rewriting the pages? It transforms the title text and the paragraph text but doesn't do anything to the HTML tags - that sounds like a program being run on the output.
Beats me... Guess I'll have to dig into it and find the bug. Anyways, thanks.
Link to comment
Share on other sites

Looks like your PHP file is UTF-8 encoded... good for you!Now, the problem is making sure PHP outputs UTF-8 encoded HTML too. You can do that by adding an appropriate HTTP header, like so:

<?php header('Content-Type: text/html;charset=UTF-8'); ?><html><head><title>PHPTest</title></head><body><?php$salutation = "Hello, World!";echo "<p> $salutation </p>";?></body></html>

Make sure there is NOTHING before this first "<?php". Not even a whitespace! Otherwise, you'll get a "... headers already sent ..." error.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...