/    Sign up×
Community /Pin to ProfileBookmark

PHP/HTML issue on linux

Hi everybody and thank you for reading ?

I have a problem running a very simple php page including html content. I can get phpinfo() and echo() pointless “hello world” but as I try to run the following script I got from a tutorial :

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”fr-FR” lang=”fr-FR”>
<head>
<title>Hello World!</title>
<meta content=”text/html;charset=utf-8″ http-equiv=”Content-Type”>
<meta content=”utf-8″ http-equiv=”encoding”>

</head>
<body>
<?php

echo htmlentities(‘hi world’, ENT_QUOTES, ‘utf-8’);

?>
</body>
</html>

I get the same error message over and over :

“GET [url]http://localhost/hello3.php[/url] [HTTP/1.0 500 Internal Server Error 0ms]
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.”

I am running it with Iceweasel (which is almost exactly the same as firefox as far as I know) and with apache2 on a debian (linux). It is in the right folder (/var/www) and if I remove the HTML headers and all the stuff, a echo() works. The “HTML stuff” seems to be the source of the problem but I can’t understand why.

Please if someone understands what is going on here I would be glad to get some help.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 24.2015 — Either make sure PHP short-open-tags are disabled, or else use PHP to output the <? xml tag:
[code=php]
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" lang="fr-FR">
[/code]
Copy linkTweet thisAlerts:
@rootJun 24.2015 — Double posting is pointless, wastes time with people answering the same question. If your question isn't answered, bump the original... simple.
Copy linkTweet thisAlerts:
@coconut_cakeauthorJun 26.2015 — Either make sure PHP short-open-tags are disabled, or else use PHP to output the <? xml tag:
[code=php]
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" lang="fr-FR">
[/code]
[/QUOTE]


THANKS ! The use of php to output the XML tag is working perfectly.

But about the short-open-tags, my previous default value was On, so I switched it Off in my php.ini :

; short_open_tag

; Default Value: Off

; Development Value: Off

; Production Value: Off

But it seems to have no effect on my previous script. Anyway I can know go on with my tutorial now, thanks a lot nogdog, you da real mvp.

And to ., sorry but I didn't get what you mean, I don't think I made a double post or anything lik this. But if I did or if I offended you somehow, well sorry, my apologies to you and to the whole community :o
Copy linkTweet thisAlerts:
@jedaisoulJun 26.2015 — It is good that your problem has been solved, but I just wonder why you are using XHTML? I would have thought that the main (only?) reason for using that variant of HTML is if you are experienced in it, and are used to its peculiarities. Surely, anyone learning HTML now, would be best advised to learn HTML 5?
Copy linkTweet thisAlerts:
@coconut_cakeauthorJun 27.2015 — It is good that your problem has been solved, but I just wonder why you are using XHTML? I would have thought that the main (only?) reason for using that variant of HTML is if you are experienced in it, and are used to its peculiarities. Surely, anyone learning HTML now, would be best advised to learn HTML 5?[/QUOTE]

Actually I am following a tutorial which is a bit old (yet quite good, I didn't find a better one in french), and at the time it was written (I think it's been written in 2008), HTML5 was quite new ... Maybe that's why ?
×

Success!

Help @coconut_cake spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...