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 #181663 is a reply to message #181660] Fri, 24 May 2013 19:34 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 5/24/2013 2:26 PM, J.O. Aho wrote:
> 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 ---
>

This also only bypasses the problem - and will require a redirect for
the life of the website (even if he changes hosts).

Better is to put in a 301 redirect for the pages; search engines will
pick up the redirect and link to the new page.

It can be done easily in the .htaccess file (more info on how to do it
correctly an alt.apache.configuration).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Sat Nov 23 22:31:44 GMT 2024

Total time taken to generate the page: 0.07034 seconds