Community
    • Login

    problem with php code in html file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 3.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Piloto EstrellasP
      Piloto Estrellas
      last edited by

      I made an html file containing php simple code, but nothing appears on monitor!!
      my html file:
      <!DOCTYPE html>
      <html>
      <body>
      <?php
      $foo = “foobar”;
      $bar = “barbaz”;
      echo “foo is $foo”; // foo is foobar
      ?>
      </body>
      </html>
      I’ m trying to solve a bigger problem (I’ m trying to handle a db through html, css, php, xampp) when I found out the above.
      PLEASE HELP!!

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Piloto Estrellas
        last edited by

        @Piloto-Estrellas

        what do you mean by saying nothing appears on monitor?
        You don’t see the code you posted within notepad++?
        You don’t see the html page if you open the page?
        If so, how do you call it, meaning what is used to call the php code?

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • Piloto EstrellasP
          Piloto Estrellas
          last edited by

          When I open the html file with my browser (Chrome, Edge, Mozilla), nothing appears on monitor. When I put text outside of the php code (in the html file written via notepad++), this text has no problem appearing on my monitor when I refresh the html file. example:
          <!DOCTYPE html>
          <html>
          <body>
          I can read
          <?php
          $foo = “foobar”;
          $bar = “barbaz”;
          echo “foo is $foo”; // foo is foobar
          ?>
          this but not “foo is foobar” which should appear
          </body>
          </html>

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank @Piloto Estrellas
            last edited by

            @Piloto-Estrellas

            you need to understand that the browser doesn’t execute your php code, in fact the browser do only
            understand html. It’s the webserver which executes the php code and makes proper html out of it,
            which then is sent to the browser.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors