November 5, 201214 yr Hello guys, I have a quick question. I have had a friend design websites for me in the past, but I want to start building my own. He has always started the site with a .php file 'index.php', but what is the difference/limitations of starting my website in .html 'index.html'? I will be using CSS. I am using Dreamweaver to do the building. Cheers in advance
November 5, 201214 yr Depends on what you want the page to achieve. Giving them the .php extension will mean you can implement PHP code into your pages. If you are just starting out, you probably want to get to grips with HTML and CSS before messing around with the fun stuff, so until you actually need to use PHP in one of your pages, for example to put the current year on your page.. <?php echo date('Y'); ?> You can safely name your pages .html (or .htm) with no problems. Edited November 5, 201214 yr by Lewwy
November 5, 201214 yr Author Thanks Lewwy. i understand that there might be a way to convert the HTML file to PHP further down the line? Also, you can work in HTML within the PHP file anyway right so can do it all in there? For example, if I wanted to eventually start building wordpress templates then .PHP would be the way to go? Cheers Edited November 5, 201214 yr by 19at
November 5, 201214 yr To convert a .html file into .php you just Right click > Rename (or any other method to rename the file). You won't have a choice as far as WordPress is concerned. It's built with PHP, so yeah, the files will need to be .php. What you might be best off doing, is always naming your files .php, even now. helloworld.php doesn't throw up an error if it doesn't have any PHP in it, it just gets on with it and shows you the HTML. Having said that, I don't know if there are any security risks, like if it will make your pages any more vulnerable? Maybe someone smarter than me could clear that up.
November 5, 201214 yr Author Hi NOCK, Could you please elaborate about what XAMPP is? and how do I go about installing this? Would this be something I would need to talk to the hosting company about? I get the impression that .PHP would be the way to go eventually, as dynamic content would be useful to learn. Cheers
November 5, 201214 yr Author To convert a .html file into .php you just Right click > Rename (or any other method to rename the file). You won't have a choice as far as WordPress is concerned. It's built with PHP, so yeah, the files will need to be .php. What you might be best off doing, is always naming your files .php, even now. helloworld.php doesn't throw up an error if it doesn't have any PHP in it, it just gets on with it and shows you the HTML. Having said that, I don't know if there are any security risks, like if it will make your pages any more vulnerable? Maybe someone smarter than me could clear that up. Thanks Lewwy - I get the impression whatever I can do in the .HTML file I can do in the .PHP so might as well start my site design in that, and when I am ready to insert dynamic content I won't have to convert anything.
November 5, 201214 yr There isn't anything to "convert", naming a file with the .php extention will allow you to use php code within the file. If you want to name it .php and fill it with pure html you can do.
November 5, 201214 yr Author There isn't anything to "convert", naming a file with the .php extention will allow you to use php code within the file. If you want to name it .php and fill it with pure html you can do. Cheers Aaron, I think that'l be the way to go too!
November 5, 201214 yr Hi NOCK, Could you please elaborate about what XAMPP is? and how do I go about installing this? Would this be something I would need to talk to the hosting company about? I get the impression that .PHP would be the way to go eventually, as dynamic content would be useful to learn. Cheers XAMPP is a local web stack - a web server (Apache) scripting language (PHP) and database server (MySQL) that you install on your machine to develop PHP-powered sites locally.
November 5, 201214 yr Author XAMPP is a local web stack - a web server (Apache) scripting language (PHP) and database server (MySQL) that you install on your machine to develop PHP-powered sites locally. So if I was to upload these files, does 'all the above' have to be installed on the hosting server?
November 5, 201214 yr All that stuff will already be on the server in 99% of cases (the whole point of packages like XAMPP is to replicate what's available on the server locally), but it's always a smart idea to develop locally and only upload when it's finished. Edited November 5, 201214 yr by Renaissance-Design
November 5, 201214 yr In most cases you won't have to worry about these things when uploading to paid hosting, these will already have been taken care of by the hosting company. You just need to make sure when buying hosting, that they are included, which, as I say, is usually the case. Installing XAMP is easy, you just run through a wizard and point it at the right folder on your machine.
November 5, 201214 yr As others have said, .php means the script can contain PHP code and thus you can do serverside operations and processing before the HTML/CSS is delivered to the client. I will add though, if you start with .html and want move over to .php learn how to beautify your URL's with HTACCESS (it's easy) so you don't break extensions when you change to PHP. So about.html would be accessed as yourdomain.com/about and it wouldn't matter if the extension was .html or .php or whatever else.
November 5, 201214 yr Author Cheers guys - will install the XAMP locally to get a feel of things. Got a feeling it might be a little advanced for me at the mo, but going to install it ready for when i need it. Really appreciate the help guys.
November 5, 201214 yr Author As others have said, .php means the script can contain PHP code and thus you can do serverside operations and processing before the HTML/CSS is delivered to the client. I will add though, if you start with .html and want move over to .php learn how to beautify your URL's with HTACCESS (it's easy) so you don't break extensions when you change to PHP. So about.html would be accessed as yourdomain.com/about and it wouldn't matter if the extension was .html or .php or whatever else. Thanks Fizix. Got a feel for this I think, never heard of HTACCESS, sounds daunting. I can probably avoid this if I go directly into .PHP?
November 5, 201214 yr Thanks Fizix. Got a feel for this I think, never heard of HTACCESS, sounds daunting. I can probably avoid this if I go directly into .PHP? You don't want to avoid it really. Friendly url's without the extension have quite a few benefits; such as users not having to remember the pages extension and allowing you to easily change the way the site works (i.e. through to a cms later) without having to worry to much about how that will affect your websites link structure. You can also use htaccess to redirect people away from old depreciated pages to new ones automatically. HTACCESS is a file (named .htaccess - note that there is no name before the .) that contains rules for how the server will handle requests. You just map the name to x extension (so about will map to about.html or about.php - and later if you get advanced, through an MVC framework - but don't worry about that just yet). There are loads of tutorials on how to create htaccess rules and it really is simple. It's not daunting at all. Edited November 5, 201214 yr by FizixRichard
November 5, 201214 yr My advice from reading 19at's responses would be to just avoid PHP for now. Everything said on here is true of course but I don't think you're at a level where you need to worry yourself about PHP files, just get to grips with HTML for now would be my suggestion, for your first site at least.
November 5, 201214 yr Author You don't want to avoid it really. Friendly url's without the extension have quite a few benefits; such as users not having to remember the pages extension and allowing you to easily change the way the site works (i.e. through to a cms later) without having to worry to much about how that will affect your websites link structure. You can also use htaccess to redirect people away from old depreciated pages to new ones automatically. HTACCESS is a file (named .htaccess - note that there is no name before the .) that contains rules for how the server will handle requests. You just map the name to x extension (so about will map to about.html or about.php - and later if you get advanced, through an MVC framework - but don't worry about that just yet). There are loads of tutorials on how to create htaccess rules and it really is simple. It's not daunting at all. Once again, cheers for the advice, i'll have a read up and update you on progress. All seems a ok at the mo. Thanks again.
November 5, 201214 yr I'd just like to add that if you are on a windows machine, then you'd need WAMP, not XAMPP
November 5, 201214 yr I'd just like to add that if you are on a windows machine, then you'd need WAMP, not XAMPP Not true.
November 5, 201214 yr As others have said above, yes you are limited with .html/.htm as opposed to .php, giving you the option to move to a CMS platform such as WordPress in the near future if you require. If you want to test the website locally in DreamWeaver, .html/.htm works well, but you'll be troubled with .php unless you have some kind of server space to play with.
November 6, 201214 yr Author As others have said above, yes you are limited with .html/.htm as opposed to .php, giving you the option to move to a CMS platform such as WordPress in the near future if you require. If you want to test the website locally in DreamWeaver, .html/.htm works well, but you'll be troubled with .php unless you have some kind of server space to play with. Thanks Silverbolt, at the minute I am testing locally so html will be perfect for what I am doing at the moment. But I understand that if I want to start working on .PHP locally then i need to install XAMPP or equivalent on my machine. Cheers
November 13, 201214 yr As long as you provide inline PHP that nests with your commands and your command is recognized as executable, then there shouldn't be a problem with .html. However, with large PHP files, I've learned it's simpler to just use the .php extension. It also looks cooler
November 14, 201214 yr I'm surprised no one's said this yet, but the big advantage of PHP for simple sites is that you can share elements between pages. So you might have your header HTML code and if you want to change something about it, you'd have to edit each page one by one. PHP allows you to have one single chunk of HTML code which your web pages can all refer to, so if you want to change something you only have to edit it once. Hope this makes sense. I've written a post about this on my blog, I'd link to it but I don't want to get banned by the forum as I've only just joined.
Create an account or sign in to comment