PHP vs. HTML


#1

Hello,

I’m asking this question more out of curiosity.

So, under page settings, Blocs gives the option of using HTML or PHP as file type.

08 PM

What are the pros and cons of using HTML or PHP? When would you use one over the other?

Thanks for satisfying my curiosity :wink:


#2

In theory .html would have a slight, very slight performance advantage, but we are talking a few milliseconds here and it would only be an issue if you had huge chunks of traffic arriving. The advantage of using php is that certain functionality can require a page to be .php, so these days I’m setting everything as .php from the start.

There is no obvious reason why you can’t have half a dozen pages as .html and a few others as .php. It won’t make any difference to your search ranking or the way pages appear online, however I think it makes sense sticking to one or the other and I would like Blocs to have a default option when creating new pages, so I don’t have to set it manually every time.


#3

PHP is a processing language that runs on most webservers. It can be used to calculate stuff, read/write to databases, etc.

Typically PHP generates a HTML page by injecting a HTML template with calculated results, so most PHP pages are essentialy a mixture of static HTML code that is updated by the PHP processor to form a web page.

If you have no PHP processing content there’s no reason to use a PHP extension and it’s likely to make your web page render more slowly by forcing a request from the web server to process the page rather than serve it from any cached version in the browser or webserver cache.

If you do select php and there’s no PHP code present, then the page will just be served as-is with no changes made to it.


#4

An afterthought, but if you start with a page as .html and later convert it to .php or vice versa it’s probably worth setting up a 301 redirect on the server.


#5

The speed difference is not even measurable on most web servers. If you’re not using any PHP code, there’s no reason to use it, and if you do need it make sure, the version of PHP matches the code.
If you switch from one to the other, on your home page make sure you delete the old HTML page. Since visitors don’t specify the full file name with Html or PHP(apple.com/index.php). The homepage is named index.html or index.php. If you leave both published, the web server will choose what one to serve.


#6

Thanks for everyone’s replies! You’ve all been very helpful.