FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » why php echo does not show up in HTML?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: why php echo does not show up in HTML? [message #181660 is a reply to message #181617] Fri, 24 May 2013 18:26 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 24/05/13 11:06, steve nospam wrote:

> I found the problem.
>
> I needed to modify the .htaccess file. added this line
>
> AddType application/x-httpd-php .htm
>
> Now it works. php works from inside htm file. No need to change file
> extension.

No, you didn't solve anything at all, you just managed to break your
site to not work properly.

When you add that line, all the pages ending with ".htm" will be sent
trough the PHP parser and the majority of your pages will not include
PHP which means you do something unnecessary by sending them to the PHP
engine which has to read the whole file and do nothing more.

The fix is rename the files to .php and remove the line from your
htaccess file. If pages which before been called whatever.htm will
suddenly be whatever.php, then use Rewrite rules to redirect the user to
the new page.

RewriteEngine On
RewriteRule ^whatever.htm$ whatever.php

Now your site will work at the majority of web hosting companies as you
have your PHP in .php files and RewriteRule is in most cases allowed.


Note: When people say you can use PHP in HTML, they ain't talking about
the file extension, but that you can mix plain HTML with PHP code, for
example:

--- example.php ---
<html>
<head>
<title>example file with mixed php and html</title>
</head>
<body>
<h1><?php echo "this is an example"; ?></h1>
<?php echo "this code is quite stupid, but shows how you can make a
badly coded site"; ?>
</body>
</html>
--- eof ---

--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Contact Form, mt-rand(), problem Validating 1 input
Next Topic: Parsing mbox files with Windows Php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 04:59:22 GMT 2024

Total time taken to generate the page: 0.05079 seconds