- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
function isfrist($val1) { return (is_frist($val1) || ($val1 == 'FILE_NOT_FOUND')); }
Admin
Let me guess. Some database interface layer (or something) would sometimes coerce a NULL to an empty string? So things began breaking until
isnull
was added?Admin
Admin
I'm confused - last time I wrote something in PHP there was only the function isset() to check for nullability. Making an extra function for something basic feels to my rather pointless.
BTW php has also a null aware equality operator (similar to JS):
Admin
Oracle itself (and MS dynamics) coerce an empty string to null so the problem isn't necessarily just in the DB interface layer. SQL server on the other hand does differentiate between null and empty string but doesn't differentiate between an empty string and one containing only spaces. The moral is clear - don't trust anybody or anything
Admin
function what_is_trwtf() { return "PHP"; }
Admin
Underscoring the importance of picking a good programming language
Admin
A bad workman blames his tools. A good one gets to pick his. The rest of us laugh at our own misfortune.
Admin
void ArmNuke() { Arm_Nuke(); AimAtFoot(); LaunchNukeExplosion(); }
FTFY
Admin
Personally I prefer the world altering missile.
Admin
PHP is an endless source of WTFs. The design of the language (or rather absence of intentional design) is a WTF of its own.
Admin
PHP: when you look at Perl and say, "I can make something simpler!". And then you fail, but everyone still uses it because of mod_php in Apache, and mod_perl wasn't meant for multi-tenant deployment.
Hey, it got us into e-commerce.
Admin
Which is treated as an "obvious" thing by Oracle fans... and is a TOTAL NIGHTMARE for who must develop applications that work well with multiple databases! Every year we have one or two angry customers because of a "NULL vs empty" bug in one of our applications :(
Admin
These bugs will never go away. NULL and empty string have distinct meanings, however, those meanings don't translate into UIs very well. For example, if a form has a checkbox that says "Ship to another address". The UI will usually disable the address text controls when said box is not checked. However, the UI serialization layer will most likely serialize those disabled fields as empty strings.
I have also witnessed an individual "clearing a textbox" with the space bar. When he tabbed into it, the entire text was automatically selected, so hitting the spacebar seemed to clear it. Since the UI used a proportional font, the single space that replaced the previous text was so much smaller that it looked very similar to just the cursor. Enjoy the resulting single space in the database!
Of course, really good database design can often help. But, the developer culture of "if it works, ship it" is working against us every step of the way. I'm actually looking forward to the day when AI based coding does all of the "easy things" so that professional developers will distinguish themselves not by doing the easy things faster, but by being able to do the hard things.
Admin
sigh The Real WTF is a dev paradigm that treats nulls and empty strings as the same thing without actually making sure the one you don't want is always turned the other.
I've encountered databases treating empty strings as null before. Evil, evil practice.
Admin
I would prefer Oracle's behavior in this case, honestly. Usually blank string is a means to meet a requirement where a more stringent value is expected but the system was lazily built w/o all the constraints and/or udts to specify behavior/rules more accurately.