pickin' on php

March 20, 2003 under Computers, Programming

To quote Dennis Miller, “I don’t want to get off on a rant here…”

But I have to. Earlier in the week, Barry asked me for help with project he’s undertaken at work. I don’t know the entire scoop, but in my summation it’s a web-based scheduling app. He’s using XML to store the scheduling data and PHP to manipulate it. He asked me to help him exploit some of expat‘s XML-parsing abilities with PHP. Now this week for me has been hectic to say the least. I had never used expat before and I wasn’t about to learn about it during this crazy week. Since Barry was hung up on a search-and-replace feature, I figured I’ll use what I already know. Eventually, Dreamcatcher Interactive themselves said they’d pay me to develop this script. Paid? About damn time. I be poor. Anywho, my complaint is with PHP and most web languages in general; sepcifically the likes of PHP and JavaScript. In this case, PHP is in my crosshairs. Most solid modern programming languages contain at least one function or method that can be used to find substrings within a string. Perl has index(), Visual Basic has InStr() and Java has indexOf(). C++ prvides you with choices o’ plenty. If you go the MFC route, the CString class has the Find() function. If you take the STL path instead, you have the like-named find() function as well. What do all of these have in common? If the substring is not contained in the string, they return -1 (except for STL’s find(), which returns the unsigned integer string::npos). Now with PHP, I planned to use a function called strpos(), which should return the index within a string that a substring is found. So if the substring begins at the beginning of string, that would be in position 0. But strpos() returns false if the substring isn’t found, which is also 0. Hmmm. Why? Bad desgin, IMHO. stristr() took care of that.

I am addicted. I must listen to Idlewild’s‘s “The Remote Part” and The New Folk Implosion album. It’s like I’m back in highschool when I had to listen to any given album.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>