Apr 27
“Uh Oh!” as my daughter would say. I was tagged to write a poem, yes thats right, me. Kelly Cho tagged me in her poetry post that was originally started by Stretsh’s meme to see how poetic bloggers are. Lets see, its been somewhere around 10+ years since I had to write a poem, so lets see if I can put something together here. This will be an original piece, and I do mean piece, by RJ “Bobs” Matthis. I definitely know I am not a poet, but lets see if I can have fun with this anyway
The PHP Tree…
From your roots that were planted by Rasmus Lerdorf
To your expanding branches fed by Coder’s hard work
Oh why do people refuse to use strtotime()?
The correct function for the job makes your app sublime
Using substr() I can return chosen partial strings
Or I will start a while() loop that returns many things
Always use a switch() statement if options are many
Too many elseif() statements will drag you down plenty
Filter the input and always escape output if User Entry
Security is most important, not just complementary
Preventing MySQL injections is a very important thing!
So always be sure to use mysql_real_escape_string()
My PHP Tree, how beautiful are your functions
Since finding you I have never felt any compunction
Using your objects & functions makes me a happy fellow
Oh PHP, you have had me ever since typing echo()
by RJ “Bobs” Matthis
So thats it, that is my poem. Basically the logicalness you would expect from a programmer, you’re just lucky I didn’t throw in some binary chains (010101010101) in there somehow. So if you are interested in sharing your poetic spirit, I would like to tag the following 3 people: Saman, 2Perfect, & Melanie
Share This
Mar 28
I am a user note maintainer on the php Documentation team. I spend a lot of time everyday reading new notes and comments that have been added to the documentation. It is us maintainers that decide whether a user note stays in the documentation or needs to be removed. We simply just have to ask ourselves: “Does this note or comment truly bring a good amount of benefit to the reader, or is it just taking up space and/or repeating what has previously been said?”.
There are definitely some gems. A lot of passionate people out there come up with some excellent ideas, examples, and suggestions. If that was all there was, we would not be needed to help maintain the user notes. Unfortunately, the majority of the notes fall more into the garbage category.
I wanted to take this opportunity to talk about a certain php function that just does not get used in situations it ought to be used in. I am talking about strtotime(). I can not tell you home many times I have had to delete a note because it consisted of 10+ lines of code that in the end, determined what day was last Monday. With strtotime(), its as easy as writing strtotime(”Last Monday”) - and than bam, you are returned the Unix time stamp of last Monday.
Is strtotime() limited to just this use? - NO! They have packed in so many amazing string variables into this function that its ease of use is amazing. If you have a badly formatted date string that strtotime() does not understand, its easy enough to correct that date string and put it in a readable format with other php functions and still in the end, you have coded so much less than you would have if you were using some of the functions I have seen.
I guess I would understand if this function was a php5 only function, since it seems so many people are out there and not up to date with the latest php. But that is not the case, strtotime has been available since php4! This simple little function can be so useful. I highly suggest that if you code php and deal with a lot of awkward formed date strings, you need to look into this function.
Share This