When Can PHP be mixed inline w/ HTML?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • one man army

    When Can PHP be mixed inline w/ HTML?

    I have looked for a definitive answer for this and have not found one.
    "sometimes, when it works" is not getting very far in designing a
    solution. Maybe the question should be "WHERE can PHP be mixed inline in
    the file?"

    for example, a file called xxx.html, marked
    DocType -//W3C//DTD HTML 4.01 Transitional//EN

    the server can execute PHP, I am using PHP v.4.4.0

    thanks
  • Alvaro G. Vicario

    #2
    Re: When Can PHP be mixed inline w/ HTML?

    *** one man army escribió/wrote (Mon, 23 Jan 2006 18:48:45 GMT):[color=blue]
    > I have looked for a definitive answer for this and have not found one.
    > "sometimes, when it works" is not getting very far in designing a
    > solution. Maybe the question should be "WHERE can PHP be mixed inline in
    > the file?"
    >
    > for example, a file called xxx.html, marked
    > DocType -//W3C//DTD HTML 4.01 Transitional//EN[/color]

    Anywhere.

    Of course, you need that the resulting parsed file makes sense, unlike
    (e.g.):

    <html<? echo 'Hello, world!'?>>



    --
    -+ Álvaro G. Vicario - Burgos, Spain
    ++ http://bits.demogracia.com es mi sitio para programadores web
    +- http://www.demogracia.com es mi web de humor libre de cloro
    --

    Comment

    • Jerry Stuckle

      #3
      Re: When Can PHP be mixed inline w/ HTML?

      one man army wrote:[color=blue]
      > I have looked for a definitive answer for this and have not found one.
      > "sometimes, when it works" is not getting very far in designing a
      > solution. Maybe the question should be "WHERE can PHP be mixed inline in
      > the file?"
      >
      > for example, a file called xxx.html, marked
      > DocType -//W3C//DTD HTML 4.01 Transitional//EN
      >
      > the server can execute PHP, I am using PHP v.4.4.0
      >
      > thanks[/color]

      Basically it can be mixed anyplace in the file.

      You just need to set your Apache configuration to process the pages
      through the PHP parser.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • ming

        #4
        Re: When Can PHP be mixed inline w/ HTML?

        one man army wrote:[color=blue]
        > I have looked for a definitive answer for this and have not found one.
        > "sometimes, when it works" is not getting very far in designing a
        > solution. Maybe the question should be "WHERE can PHP be mixed inline in
        > the file?"
        >
        > for example, a file called xxx.html, marked
        > DocType -//W3C//DTD HTML 4.01 Transitional//EN
        >
        > the server can execute PHP, I am using PHP v.4.4.0
        >
        > thanks[/color]

        <p>this is an <?php= $level ?> example</p>

        Comment

        • Ken Robinson

          #5
          Re: When Can PHP be mixed inline w/ HTML?


          ming wrote:[color=blue]
          >
          > <p>this is an <?php= $level ?> example</p>[/color]

          Your file needs to have the file extension of ".php" if it is
          ".anythinge lse" it won't work.

          Ken

          Comment

          • NC

            #6
            Re: When Can PHP be mixed inline w/ HTML?

            one man army wrote:[color=blue]
            >
            > I have looked for a definitive answer for this and have not found one.[/color]

            The answer is very simple: when PHP code and HTML are out into a file
            with *.php extension.
            [color=blue]
            > for example, a file called xxx.html, marked
            > DocType -//W3C//DTD HTML 4.01 Transitional//EN[/color]

            Normally, HTTP servers are configured not to treat *.html files as
            those that contain no executable code. So if you put PHP code into an
            *.html file, it will not be executed.

            Cheers,
            NC

            Comment

            • NC

              #7
              Re: When Can PHP be mixed inline w/ HTML?

              one man army wrote:[color=blue]
              >
              > I have looked for a definitive answer for this and have not found one.[/color]

              The answer is very simple: when PHP code and HTML are put into a file
              with *.php extension.
              [color=blue]
              > for example, a file called xxx.html, marked
              > DocType -//W3C//DTD HTML 4.01 Transitional//EN[/color]

              Normally, HTTP servers are configured not to treat *.html files as
              those that contain no executable code. So if you put PHP code into an
              *.html file, it will not be executed.

              Cheers,
              NC

              Comment

              • Iván Sánchez Ortega

                #8
                Re: When Can PHP be mixed inline w/ HTML?

                -----BEGIN PGP SIGNED MESSAGE-----
                Hash: SHA1

                Ken Robinson wrote:
                [color=blue]
                > Your file needs to have the file extension of ".php" if it is
                > ".anythinge lse" it won't work.[/color]

                Wrong. You can configure your web server software to
                process .php, .html, .shtml, .whatever files through the PHP engine.

                (However, this is obviously not the default, and newbies should name their
                files with the .php extension in order to avoid confusions)

                - --
                - ----------------------------------
                Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

                Un ordenador no es un televisor ni un microondas, es una herramienta
                compleja.
                -----BEGIN PGP SIGNATURE-----
                Version: GnuPG v1.4.2 (GNU/Linux)

                iD8DBQFD1Uqw3jc Q2mg3Pc8RAqnJAJ 9Fd950zGlmn7BjK HD4q9BFlu3O8gCe NkaM
                YAcAv9alMVwVPwd 7aHCHcSM=
                =UN+I
                -----END PGP SIGNATURE-----

                Comment

                • LJB

                  #9
                  Re: When Can PHP be mixed inline w/ HTML?

                  The reply below is not entirely correct. Files with the .html extension
                  (or any other extension for that matter) can contain PHP code if they
                  are called as an <em>include</em> file.

                  NC wrote:[color=blue]
                  > one man army wrote:
                  >[color=green]
                  >>I have looked for a definitive answer for this and have not found one.[/color]
                  >
                  >
                  > The answer is very simple: when PHP code and HTML are out into a file
                  > with *.php extension.
                  >
                  >[color=green]
                  >>for example, a file called xxx.html, marked
                  >> DocType -//W3C//DTD HTML 4.01 Transitional//EN[/color]
                  >
                  >
                  > Normally, HTTP servers are configured not to treat *.html files as
                  > those that contain no executable code. So if you put PHP code into an
                  > *.html file, it will not be executed.
                  >
                  > Cheers,
                  > NC
                  >[/color]

                  Comment

                  • Chung Leong

                    #10
                    Re: When Can PHP be mixed inline w/ HTML?

                    ming wrote:[color=blue]
                    > <p>this is an <?php= $level ?> example</p>[/color]

                    The <?= ?> syntax doesn't work for <?php ?>.

                    Comment

                    Working...