ASP does not come with many string formatting options. We can find the length, make a string upper/lower case, and do some trimming and replacing, but not too much else. Often appearing in forums is the question "What's the ASP equivalent to PHP's [something] function?" This article will highlight a few formatting functions mimicking PHP, and maybe spur your creative mind on to creating more of your own.
Introduction
Anyone who has ever coded in PHP, knows how easy (and almost fun) it can be to work with strings. The creative minds behind the language realized there are some very common things people like to do with strings, so let's incorporate them right into the package. These include functions to strip HTML formatting, count words, perform smart case changes, and more.
But suppose you make a switch, even a temporary one, to ASP. Perhaps just one application or one environment you work with is ASP driven. Well, much to your dismay, you're now on your own if you want any of these advanced string functions! ASP gives you all you need to trim or count the length of a string, but that's about it. This article will help you along with a number of those functions, and no doubt you'll be able to suggest a few of your own in the forum.
For those of you who don't know or simply don't care what PHP has to offer (shame on you), you'll still find this article very handy. The ideas covered are no doubt things you've encountered in the past, and had to handle in a manual way. My objective here, is to provide some package-able, reusable functions that you can call on whenever you need. And no doubt after you've read of what they can do, you will need!
I'll go through five PHP functions, what they do, and how to create an ASP equivalent. They are:
str_word_count
ucfirst
ucwords
strip_tags
str_pad
They same imitation is the finest form of flattery, so let us proceed with flattering the PHP designers.
Sunday, October 19, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment