Using the PECL bbcode extension

UPDATE: If you are using PHP 5.4, and get an error installing the pear bbcode module, try installing “bbcode-1.0.3b1” rather than “bbcode”. See this thread for more information:


If you have a site that allows users to create their own content, you’re going to need bbcodes(aka “Bulletin Board Codes”) to make your and their life easier.

bbcodes, or html shortcuts, are the tags people use in their content, instead of standard HTML tags, that are used to markup some text, such as bolding a paragraph, creating a link, etc. Everybody’s seen them, [u] for underlining, [b] for bold, etc.

I created a rudimentary bbcode system for my projects, but it didn’t handle nested bbcodes very well, and due to my lack of regular expression expertise, the function was quite a hog on processing large amounts of content.
Continue reading “Using the PECL bbcode extension”

PHP itself isn’t that much different from COBOL

If you’re a developer, you know most languages aren’t that much different from each other, it’s just learning how to implement the current function or feature you’re looking for that’s the hard part.

I was reading this article on COBOL still accounting for 80% of business code in the world, and thought about how languages aren’t really that different from each other. For example, I’ll document some common and routine snippets of code from COBOL and PHP. It isn’t the language that’s hard to learn, it’s simple syntax, but the hard part is finding out how to get your favorite language to do what you want.

To simplify things, I’m using PHP’s alternative syntax, which means that, similar to COBOL, you don’t use { and } to enclose some statements, you use statements such as ENDIF and ENDFOR, which is how I learned it.

These should work if you’re using PHP5 and PHP4. PHP’s Object Oriented structure isn’t described here. The COBOL examples are strictly IBM z/OS COBOL, old school, no OOP required, or desired.

One thing to understand about PHP, as this is different from some other languages, is it will do a fairly good job of determining if your variable is a string or numeric, so you don’t see a lot of “wrong type” errors in PHP.

Maybe another day, or another life time, I’ll write about the similarities of CICS and PHP/Apache. They both are stateless protocols, in which in CICS you need a COMMUNICATIONS AREA to or a DATA MAP to hold variables you want to keep, and with PHP, you’d probably use a session to do the same thing. A CICS MAP isn’t a lot different from defining an HTML FORM to a user.

I haven’t included the WORKING STORAGE of the definitions of these COBOL variables, to save space, but they shouldn’t matter very much for these examples. You can define variables in PHP “on the fly”, but you may get syntax notification warnings in PHP if you try to use a variable before its definition.

If you’re a COBOL developer interested in PHP, the best place to learn it is on, search or browse through some functions to see some of the things you work with today that could work in PHP. For instance, search for the “Date” function, and browse the pages on arrays to get a feel for how those topics are presented. Each function has user contributed notes too for code tidbits or gotchas

Then, download some PHP code, and see what it’s doing. Try to avoid Object Oriented PHP code unless you’re familiar with those types of structures.

These examples below are pretty simple, if you need more complex ones, let me know. No questions about how to convert any Cobol ’74 Report-Writer or internal sorts to PHP though!

(btw, in the CNET article, it describes PHP being a “new” language, and Java and .NET, as well as COBOL, as older languages. PHP itself has been around longer than .NET, but what do you expect, it’s CNET).

Continue reading “PHP itself isn’t that much different from COBOL”