Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 05-28-2009, 09:31 AM   #1
LQ Newbie
Registered: Nov 2006
Posts: 16

Rep: Reputation: 0
Question gentoo - php in html files?

Is it possible to somehow have php code in .html-files?

If I rename the index.html to index.php or index.phtml, it says syntax error, where there is html code, since it expects php code.

if I rename it back to index.html, I cannot get the php code running. I find this weird! how do I mix php and html while having html as default language?

<?xml version="1.0" encoding="iso-8859-1"?>

<?php phpinfo(); ?>
Old 05-28-2009, 10:10 AM   #2
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Could you please post the exact error you see in your browser when you try to rename "index.html" to "index.php"?

You should not be getting an error if you have PHP and HTML in the same PHP file; I do it all the time as I would rather break from a <?php ... ?> section than stay in it and use a whole whack of "echo()"s.

<title>Page title</title>
<head> Something...</head>
      for ($i = 0; $i < 100; ++$i) { echo("$i "); }
It could be your HTTP server isn't configured properly. When there are nice tools available, I will use Apache, otherwise it is lighttpd all the way; it is much easier to get up and running, and tweak.

EDIT: Okay, when I tested your index.html file (as index.php) it didn't run, but I didn't get an error. I finally got it to work when I removed the "<?xml ... ?>" section.

Last edited by indienick; 05-28-2009 at 10:13 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge Of Html Files Into A Single Html (or Pdf) fiomba Linux - Software 6 06-20-2011 07:28 PM
Gentoo Linux - how to map Apache server to look at php files in multiple locations bg108 Linux - Newbie 3 02-07-2008 04:51 AM
Apache rending php when filename is x.php.html mastahnke Linux - Server 6 01-22-2007 08:39 AM
converting a doc/ppt Windows files in html files under linux env agrosu Programming 7 02-23-2006 03:07 PM
html code and including html files Hockeyfan Programming 2 08-22-2005 05:11 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration