Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 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
    New Coder
    Join Date
    Aug 2011
    Posts
    51
    Thanks
    6
    Thanked 12 Times in 12 Posts
    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?>

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Aug 2011
    Posts
    51
    Thanks
    6
    Thanked 12 Times in 12 Posts
    I'm not sure what you're trying to do exactly. Could you explain more?

  • #5
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,312
    Thanks
    4
    Thanked 206 Times in 203 Posts
    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

  • #6
    New Coder
    Join Date
    Aug 2011
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @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?

  • #7
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,312
    Thanks
    4
    Thanked 206 Times in 203 Posts
    Quote 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.

    Quote 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

  • #8
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •