Does PHP need the .php extension ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cyrus D.

    Does PHP need the .php extension ?

    Hi guys,

    When I use PHP I give my file the .php extension. I always wondered if it
    could be an .htm page with a <script> block that the PHP resides in, the
    same way you would do JavaScript. If you can do it that way are there any
    benifits to that method ?

    Take care,
    Cyrus


  • John Murtari

    #2
    Re: Does PHP need the .php extension ?

    "Cyrus D." <satan@invalid. org> writes:
    [color=blue]
    > Hi guys,
    >
    > When I use PHP I give my file the .php extension. I always wondered if it
    > could be an .htm page with a <script> block that the PHP resides in, the
    > same way you would do JavaScript. If you can do it that way are there any
    > benifits to that method ?
    >
    > Take care,
    > Cyrus
    >
    >[/color]
    Right now you probably have a directive like this in your
    httpd.conf file (or your ISP does).

    AddType application/x-httpd-php .php4 .php .php3 .inc .inf .phtml

    It identifies the extensions which should be processed by the
    php interpreter before output is sent to the browser. I believe
    you can also include this directive in a .htaccess file in your
    area and add .htm to the list. This would send all your files
    throught the interpreter and those that do not contain PHP code
    would just be passed through....

    You mention Javascript, but that is a bit different. The
    interpretation of that happens at your browser -- all the PHP
    work is done at the server.

    Hope this helps.
    --
    John
    _______________ _______________ _______________ _______________ _______
    John Murtari Software Workshop Inc.
    jmurtari@follow ing domain 315.635-1968(x-211) "TheBook.Co m" (TM)

    Comment

    • jrf[no]

      #3
      Re: Does PHP need the .php extension ?

      Cyrus D. wrote:[color=blue]
      > Hi guys,
      >
      > When I use PHP I give my file the .php extension. I always wondered if it
      > could be an .htm page with a <script> block that the PHP resides in, the
      > same way you would do JavaScript. If you can do it that way are there any
      > benifits to that method ?
      >
      > Take care,
      > Cyrus
      >
      >[/color]


      1. You can use the .htm extension and tell the server through .htaccess
      to treat any .htm file as a php file
      2. Within a html page (which is treated as php via the above method) you
      can have a php block by surrounding the block with: <?php and ?>

      If you like to have a "clean" and easily maintainable site, I would
      personnaly prefer a seperation of languages as much a possible.
      In that case there really would be no benefits to using the above method.

      Each to their own however, you may find it useful.

      J.

      Comment

      • Alvaro G Vicario

        #4
        Re: Does PHP need the .php extension ?

        *** Cyrus D. wrote/escribió (Tue, 09 Nov 2004 16:56:46 GMT):[color=blue]
        > When I use PHP I give my file the .php extension. I always wondered if it
        > could be an .htm page with a <script> block that the PHP resides in, the
        > same way you would do JavaScript. If you can do it that way are there any
        > benifits to that method ?[/color]

        Your web browser must have a rule about what files should be passed to PHP
        interpreter (you probably don't want to parse JPEG files ;-) That rule is
        normally based in file extension. There's also a tweak called x-bit hack
        that works under Unix.


        --
        -- Álvaro G. Vicario - Burgos, Spain
        -- Thank you for not e-mailing me your questions
        --

        Comment

        • Michael Fesser

          #5
          Re: Does PHP need the .php extension ?

          .oO(Alvaro G Vicario)
          [color=blue]
          >*** Cyrus D. wrote/escribió (Tue, 09 Nov 2004 16:56:46 GMT):[color=green]
          >> When I use PHP I give my file the .php extension. I always wondered if it
          >> could be an .htm page with a <script> block that the PHP resides in, the
          >> same way you would do JavaScript. If you can do it that way are there any
          >> benifits to that method ?[/color]
          >
          >Your web browser must have a rule about what files should be passed to PHP
          >interpreter [...][/color]

          s/browser/server/
          [color=blue]
          >(you probably don't want to parse JPEG files ;-) That rule is
          >normally based in file extension.[/color]

          Sure, but it's just a matter of configuration. If you want your .foo and
          ..bar files be handled by PHP - do it. The server does what you tell him
          to do.

          Micha

          Comment

          Working...