Web Analytics Made Easy -
StatCounter Simply inserting a .php into a .html - CodingForum

Announcement

Collapse
No announcement yet.

Simply inserting a .php into a .html

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simply inserting a .php into a .html

    Hi,

    Sorry if this seems like a novice question.

    I have a .php script and I would like to call it/include it in my .html script in dreamweaver so that when I load my html the page shows the .php part.

    Many Thanks

  • #2
    You can have html in a .php file but you can't have php in a .html file. What you need to do is save that .html as php. html will work as it should, and you can place your php in there with
    PHP Code:
    <?php [php code here?>

    Comment


    • #3
      Thanks ASTP.

      Just so you are aware. I'm not looking to put the php script IN the html. I have the .php file separately. What I was hoping for is a way to call it in the html.

      Comment


      • #4
        I'm not sure what you're trying to do exactly. Could you explain more?

        Comment


        • #5
          Code:
          <?php include('name_of_your_php_file.php'); ?>
          Note however that if the extension of the file you are trying to do this in is HTML the above will not work (unless your server is configured to treat HTML files as if they were PHP files ... not likely the case).
          Dave .... HostMonster for all of your hosting needs

          Comment


          • #6
            @ASTP so for example if I had a separate css file, I can call it in my html as follows:

            <link rel="stylesheet" type="text/css" href="css/style.css" />

            So I was hoping for the same thing but with a php.

            @djm So you think once I've completed my html file, I should include your line of code in the body, and then save it as a .php?

            But then I won't be able to edit it as an html?

            Comment


            • #7
              Originally posted by Belloshoes View Post
              @ASTP so for example if I had a separate css file, I can call it in my html as follows:

              <link rel="stylesheet" type="text/css" href="css/style.css" />

              So I was hoping for the same thing but with a php.
              That does not work for PHP files.

              Originally posted by Belloshoes View Post
              @djm So you think once I've completed my html file, I should include your line of code in the body, and then save it as a .php?

              But then I won't be able to edit it as an html?
              Sure you can (though that may depend on your editor, IDE or whatever). Both extensions are really just plain text.
              Dave .... HostMonster for all of your hosting needs

              Comment


              • #8
                djm is correct. There is no real difference between .php and .html extensions. The only main difference is the apache, IIS or w/e php module will detect the .php and run it as a script, whereas it will just output the .html directly.

                Both files are plain text, and web development IDE's (dreamweaver as a horrible example :P ) will read them the same except highlight code accordingly. In other words, a .html file renamed to .php will output exactly the same thing, but will allow you to run script functions like include() etc.
                Useful function to retrieve difference in times
                The best PHP resource
                A good PHP FAQ
                PLEASE remember to wrap your code in [PHP] tags.
                PHP Code:
                // Replace this
                if(isset($_POST['submitButton']))
                // With this
                if(!empty($_POST))
                // Then check for values/forms. Some IE versions don't send the submit button 
                Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎