Using PHP to Add Content to Plain Text

In my last blog message, I described how I use a converter to HTML-ize plain text. This is useful for taking URLs like and producing a link. Now that I convert each text file before display, I can add content.

One thing I add to my web pages, is ads. Some people pay me for specific ads. On other pages, I put in filler from Google Ads.

I based my converter on functions from, particularly "txt2html". At the end of that function, when the HTML is almost ready, I can append to it. Or, since I want the ads up front, I pre-pend.

/* Ad from  Get your own ad from there, 
 * unless you want me to get paid for it! 
 * When you have the ad, they'll tell you what HTML to put in your site.
 * Cut and paste their text into the string below.
 * Put only double quotes inside the string, single quotes to define it. */ 
$html = '<' . 'table align=right> <' . 'tr> 
<' . 'td> <' . 'script type="text/javascript"><' . '!--
google_ad_client = "pub-4220969454236754";
/* 300x250, created 10/17/09 */
google_ad_slot = "6246428593";
google_ad_width = 300;
google_ad_height = 250;
<' . '/script>
<' . 'script type="text/javascript"
<' . '/script>
<' . '/td> 
<' . '/tr> <' . '/table>' . $html;
return $html;

About the Author: 

Scott Eiler has for decades worked in all aspects of software engineering, in public and private sectors, in many different industries, on projects most people know by name, as employee, vendor, and now consultant. He also maintains his own diverse web site, including much commentary. Scott knows, engineering is more than just hacking out code.

Posted in: 
Bookmark and Share