The Internet is written in a language called HTML
If you right click in a web page and select "view source" you can see the HTML that produced the page.
The HTML for most web sites is sloppy. It is either presented with a mix of indentation styles or as one huge line.
I decided that I wanted the HTML for my sites to look pretty.
The best way to assure that HTML looks pretty is to overload the print command.
I am using PHP and don't have that option. So, I developed a function which I named htag() which makes sure my code is indented correctly. Here is the PHP script for the command.
The function takes three attributes. The first is the name of the tag, followed by the attributes for the tag. The third optional attribute is the stuff between the tags.
This is how the function works:
htag('p','style="text-align: center"','The paragraph');
// The Paragraph
// If the third attribute is missing, the program will produce the tag and make note that the tag is open.
htag('article'); // Opens the article
htag('p','','A paragraph');
htag('/article'); // closes the article
// Output
//
// A paragraph
//
// If i begin the tag with a dash, it produces a self closed tag.
htag('-img','src="/nekkid-lady.jpg");
// produces
//
// If the third attribute is an array it will wrap the elements in the array with tags.
// I also added special tags to produce table headers and rows.
htag('trh','',['One','Two','Three']);
// produces
// One Two Three
This little function makes it really easy to produce web pages. Best of all the HTML is cleanly indented making it easy to see if I made a mistake in the coding of a page.