You can type an article into a word processor. That word processor would have a program you can use to convert the article into an HTML document, to be displayed on the web. The problem is that the resulting HTML document might have a lot of extra code you do not want, and the conversion may not be good. The extra code makes the resulting HTML document, long; you may not even understand some of the extra code and it becomes more difficult to edit the resulting HTML document. However, if you understand PHP, you would be able to produce the corresponding HTML document with no extra code, using a PHP program. The process is this: you save the document from the word processor as text-only file. Then you write PHP code to produce the HTML document with no extra code added. In this article I show you how to produce some HTML code, with no extra code added, using PHP, from a text file.
You may argue that there are ready-made software packages in which you can type your article directly and they will produce the HTML document for you. With these packages, the problem of extra code and editing still occur, and they do not give you a lot of flexibility with what you want to do with the resulting HTML code.
You need basic knowledge in HTML, PHP, PHP File System and PHP Regular Expressions to appreciate this article.
Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.
Overall Process
You type your article, essay, news, whatever, in your word processor. You type the article in your word processor instead of a text editor, because the word processor will allow you to check spelling and grammar and do some formatting; the formatting should be minimum in this case. Then you save the article as text-only file. This would save the file without any word processor code. Almost all word processors today allow you to save their content as text-only file. You then use the PHP program you have written to convert the text file into an HTML document. In this article the PHP program I will give you will convert the text file into a simple HTML code and not the complete HTML document. You can then copy and paste the simple HTML code into a DIV element of an HTML document template.
The PHP Program code Segments
The PHP program I present is short, but very involving. It has six code segments.
The first code segment obtains the path and name of the text file from a web page. This segment copies the file from the directory at the server and assigns the file content to a PHP variable. This variable now holds the file content in the form of a string.
When you type an article in a word processor, it may have characters such as '
Published by Chrys Forcha
I have more than 10 years experience in computer programming, software, electronics and telecommunications. I have a First Degree in Electronics and a Master's Degree in Technical Education. As well a... View profile
Peepel Web Writer: A Brand New Online Word Processor with StylePeepel Web Writer is a new player in the online word processor game. It's part of the Peepel Online Office, a slick new set of tools that may someday have Google looking over i...- Atlantis Word Processor Beginner's GuideIn this guide I will show you how to do the basic stuff in Atlantis. This is a beginner's guide for the Atlantis word processor.
- Free Alternative to Microsoft Works Word Processor
- How to Choose the Right Word Processor for Your Needs
- Schreiben - a Fast, Minimalist Word Processor for Mac
- Writer.app - a Distraction Free Word Processor for Mac
- Buzzword - the Best Online Word Processor I've Used
- Bean: A Rich Text Word Processor for Mac
- CryptoEdit - an Encrypted Word Processor for Macs




3 Comments
Post a CommentLilia, when a customer brings a text article to you that is already well typed, with grammar and spelling errors checked, the automatic program saves time. Immagine that you have many such documents to display for web sites such as this one, you would surely need an automatic program. Also remember, that the code I present does not put extra code into your final web page.
If you already have basic knowledge of HTML, there is no need to use a PHP program to convert it to HTML, that's just lazy and puts a lot of extra steps in. You can just do it yourself. It doesn't take long to convert an article if you already know even just a little bit of HTML. I always code everything by hand.
Very informative article!