• Login
Community
  • Login

problem with php code in html file

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 3.4k 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.
  • P
    Piloto Estrellas
    last edited by Dec 27, 2016, 7:38 PM

    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!!

    C 1 Reply Last reply Dec 27, 2016, 8:34 PM Reply Quote 0
    • C
      Claudia Frank @Piloto Estrellas
      last edited by Dec 27, 2016, 8:34 PM

      @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
      • P
        Piloto Estrellas
        last edited by Dec 28, 2016, 7:45 AM

        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>

        C 1 Reply Last reply Dec 28, 2016, 6:46 PM Reply Quote 0
        • C
          Claudia Frank @Piloto Estrellas
          last edited by Dec 28, 2016, 6:46 PM

          @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
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors