...

View Full Version : Simply inserting a .php into a .html



Belloshoes
09-07-2011, 08:30 AM
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

ASTP001
09-07-2011, 09:15 AM
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 [php code here] ?>

Belloshoes
09-07-2011, 10:05 AM
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.

ASTP001
09-07-2011, 10:30 AM
I'm not sure what you're trying to do exactly. Could you explain more?

djm0219
09-07-2011, 10:52 AM
<?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).

Belloshoes
09-07-2011, 11:01 AM
@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?

djm0219
09-07-2011, 11:08 AM
@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.


@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.

BluePanther
09-07-2011, 01:25 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum