How to organise the code of a website

How to organise the code of a website 1

The Best WordPress Hosting

After many years of using and jumping from hosting to hosting, we have finally found the best one, and we want to share it with you.

The other day we talked about how the work of creating a website should be organised in order to achieve an efficient result. One of its most important sections was organise the code in the correct way to facilitate possible corrections or modifications to the code. Today we will expand on this topic a little by explaining some tricks that will allow you to perfect your techniques.

How to organise the code of a website

When writing code, the best way to keep it simple and easily editable is to give it an correct visual appearance. Just a glance at the final code should make it easy to find what we want. To achieve this, there are a few rules to follow:

- When using if, while, for,... statements, their internal code must be tabulated, making each part of the code clear.

- All important parts of the code should be commented. In the comments, the usefulness of the code for future revisions should be written. If we use HTML language, the comments are written like this: . If, on the other hand, we write them in PHP, we write them in the following way: /* commentary */.

- All lines should be correctly spaced to make them easier to read. It is not the same to write if(!$_POST[‘var’]!=8){ to write if ( !$_POST['var'] != 8 ) {. In the second option, the parts of the judgment are much better identified.

- Although this is not a rule, one thing that will help us to understand the code is to use a programming program that highlights the different parts of the code. This makes every detail visually clear.

In addition to these tips, which are mostly user-dependent, there are tools that allow code to be sorted automatically. Although they are quite useful, we should not limit ourselves to always sort the code with them, as they may have a different way of sorting than we do. Some of these tools are the following:

Tabifier: Sorts the code in HTML and CSS format.

Beautify php: Sorts PHP code.

Optimum CSS: Sorts the CSS code. It is in English.

About these tools we should also know that they will not add comments for us. This task will be left to us.

As always, remember that you can go to our forum to ask any questions you may have.

Leave a Comment

Your email address will not be published.

en_GBEnglish
Scroll to Top