-
Posts
558 -
Joined
-
Last visited
Everything posted by Bob Crabb
-
Good Grief, this had me chasing my tail for a while this evening. Some of you more experienced PHP coders have probably run into it, but it is the first time that I have attempted to use nested tertiary operators, so I thought that I would share my experience. What I was trying to accomplish was fairly simple. I wanted to have the greeting on a page change depending upon whether it is morning, afternoon or evening. The different phrases are in a language array, and the array keys for the phrases are 'm' for the morning message, 'a' for afternoon, and 'e' for evening. So I needed to evaluate the hour to set the key to the right value. Of course, I could use a series of if, elseif statements, but I wanted to do this in a single line using a tertiary operator. I thought that this would work: > $hour = date(G); $key = ($hour >= 17)? 'e' : ($hour >= 12)? 'a' : 'm'; I thought that if the hour was 17 or higher the first condition shold be true, and no further evaluation would occur. BUT, what happens instead is the second condition is evaluated, therefore a $hour value of greater than or equal 17 in this case returns 'a'. I finally found that in order for this operation to behave as I had expected, the entire second condition, ie the false result of the first condition, must be enclosed in parenthesis, like this: > $hour = date(G); $key = ($hour >=17)? 'e' : (($hour >= 12)? 'a' : 'm'); Well, I try to learn something new every day, so I guess I can call it quits for the day, and go veg out in front of the television.
-
wikimedia.org just announced a security release addressing a number of cross site scripting vulnerabilites in the web-based installer. Details are here: http://lists.wikimedia.org/pipermail/media...ary/000083.html
-
I'm glad that your problem was finally resolved. Unfortunately, it seems as though there were a lot of issues with this migration. I'm sure that Tech Support was overloaded with tickets last night. I say this because I also have a reseller account on that server, and personally submitted three tickets late last night. I was impressed with the timeliness of the responses to all those tickets -- all in less than 20 minutes. I'm glad that your data was restored. I wasn't so lucky, and lost some emails and forum activity from Saturday. Apparently, when synced with the live server, some sites' data didn't transfer properly. Unfortunately for me, my sites were among those that didn't transfer properly. Fortunately, for me, I don't think that anything of importance was lost that can't be replicated (assuming that my friend who sent me some awesome pics of the Hudson River jetliner salvage yesterday morning can re-send the photos).
-
All those sound really good -- even the Subway sandwich. I got home this evening, read the mail, paid some bills, then went outside and cleaned the newly fallen snow off the driveway. When I got back inside, Ritsuko (my lovely wife) had sauteed some pork tenderloin that was marinated in garlic, chilis and soy sauce, with onions, leeks, and green beans. So, now I'm happy, warm, and well fed -- just chillin' in front of the computer. Good topic, Thomas !!!
