Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9608

Re: why php echo does not show up in HTML?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: why php echo does not show up in HTML?
Date Fri, 24 May 2013 20:26:08 +0200
Lines 53
Message-ID <b09pm1FmrntU1@mid.individual.net> (permalink)
References <78f2c263-051b-4b12-b2fc-049aeae3fdd6@z8g2000yqd.googlegroups.com> <af70263f-b09f-49cd-b3e3-95b4c04fe39f@z10g2000yqd.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net iFryuWWA12DdUs0VWviVjAUmeoLP8g8OC/nH9e6tPT33HnCyD2
Cancel-Lock sha1:8YYfSXWsDWY9VKCtVAv1PNq9A/c=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130408 Thunderbird/17.0.5
In-Reply-To <af70263f-b09f-49cd-b3e3-95b4c04fe39f@z10g2000yqd.googlegroups.com>
Xref csiph.com comp.lang.php:9608

Show key headers only | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 01:08 -0700
  Re: why php echo does not show up in HTML? "Andy" <andy@NOSPAMmanyplay.com> - 2013-05-24 09:50 +0100
    Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 09:25 -0400
  Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 01:53 -0700
    Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 01:57 -0700
      Re: why php echo does not show up in HTML? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-24 22:25 +0000
  Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 02:06 -0700
    Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 06:20 -0700
      Re: why php echo does not show up in HTML? Tim Streater <timstreater@greenbee.net> - 2013-05-24 14:40 +0100
        Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 09:55 -0400
          Re: why php echo does not show up in HTML? Tim Streater <timstreater@greenbee.net> - 2013-05-24 16:47 +0100
            Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 12:07 -0400
              Re: why php echo does not show up in HTML? Tim Streater <timstreater@greenbee.net> - 2013-05-24 18:04 +0100
                Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 13:30 -0400
            Re: why php echo does not show up in HTML? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-24 22:32 +0200
        Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 07:19 -0700
          Re: why php echo does not show up in HTML? Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-05-24 15:02 +0000
            Re: why php echo does not show up in HTML? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-24 22:37 +0000
      Re: why php echo does not show up in HTML? The Natural Philosopher <tnp@invalid.invalid> - 2013-05-24 15:00 +0100
        Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 07:20 -0700
          Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 10:35 -0400
          Re: why php echo does not show up in HTML? The Natural Philosopher <tnp@invalid.invalid> - 2013-05-24 16:59 +0100
        Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 10:34 -0400
      Re: why php echo does not show up in HTML? "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-24 10:51 -0500
      Re: why php echo does not show up in HTML? Richard Yates <richard@yatesguitar.com> - 2013-05-26 07:02 -0700
    Re: why php echo does not show up in HTML? "J.O. Aho" <user@example.net> - 2013-05-24 20:26 +0200
      Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 15:34 -0400
  Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 09:35 -0400
    Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 07:14 -0700
      Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 10:38 -0400
        Re: why php echo does not show up in HTML? steve nospam <steve.nospamm@gmail.com> - 2013-05-24 07:53 -0700
          Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 11:06 -0400
          Re: why php echo does not show up in HTML? Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-05-24 15:18 +0000
            Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-24 12:04 -0400
            Re: why php echo does not show up in HTML? gordonb.aykca@burditt.org (Gordon Burditt) - 2013-05-24 22:59 -0500
              Re: why php echo does not show up in HTML? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-25 09:20 +0200
              Re: why php echo does not show up in HTML? Jerry Stuckle <jstucklex@attglobal.net> - 2013-05-25 09:22 -0400
          Re: why php echo does not show up in HTML? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-24 22:49 +0000
            Re: why php echo does not show up in HTML? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-24 17:06 -0700
      Re: why php echo does not show up in HTML? Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-05-24 15:12 +0000
      Re: why php echo does not show up in HTML? Richard Yates <richard@yatesguitar.com> - 2013-05-26 07:13 -0700
  Re: why php echo does not show up in HTML? yousafali3949@gmail.com - 2017-07-16 07:14 -0700
    Re: why php echo does not show up in HTML? Mark Lloyd <not@mail.invalid> - 2017-07-16 09:55 -0500
  Re: why php echo does not show up in HTML? V <vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvva@hotmail.com> - 2023-07-11 22:22 -0700

csiph-web