- 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
Some people will do anything to get an email address :)
Admin
if (!$comment){ //nobody has posted yet. Just to make sure, we'll check for posts as Comment, instead global $Comment; if (!$Comment){ //where did everybody go? global $posts; if (!$posts){ //I'm getting lonely global $lonely; //I didn't even like them anyways. global $drink; //I'm glad they are gone global $drink_more; // Hey, a lamp shade... global $drink_even_more; // Sosifre, I'm not as think as you drunk I am global $pass_ou
Admin
I'd love to be the frist dev on his project to use emAilAddreSs
Admin
[There | there | THERE] [is | Is |IS] [SomeThing | Something | someThing | SOMETHING] [To | to | TO ] [Be | be | BE] [Said | said | SAID] [For | for] [Case | case | CASE] [Insensitivity | insensitivity | INSENSITIVITY]
Admin
But I want to use $emailAddress!
Admin
I PREFER CASE INTENSITY! OH YEAH!
CAPTCHA: iusto Who knows?
Admin
I think we should introduce word length / abbreviation insensitivity too, just in case people want to use
$emailaddr
...Admin
Personal Home Page. That is all.
Admin
Now if we could only specify the variable name in RegEx that would solve our problems...
Admin
That would be an awesome language feature - just imagine the potential for abuse...
Admin
where is my $EMAILADDRESS ?
Admin
Hypertext Preprocessor. That is all.
Admin
Dear Murray,
In case you can’t tell, this is a grown-up place. The fact that you insist on not using coding conventions clearly shows that you’re too young and too stupid to be using Perl.
Go away and grow up.
Sincerely, Bert Glanstron
Admin
Admin
Admin
Dear Bert,
In case you can't tell, that's PHP, not Perl. The fact that you insist on posting your juvenile Bert Glanstron jokes shows that you're too young and too stupid to be posting on TDWTF.
Go away and grow up.
Sincerely,
Everyone
Admin
Admin
What IS the argument for case-sensitive names, anyway?
Admin
This is literally the lamest WTF that has ever been posted.
Seriously, who hasn't had to do something like this?
Admin
Stupid spam filter won't let me post the one-line Unix shell equivalent.
Hint: it uses the ${parameter:-word} syntax.
Admin
Admin
Admin
I think a regexp search on the map that contains the global variables would be a superior solution.
What?
Admin
Admin
I've never done anything like this. You can tell, because I haven't flung myself off a tall building, which is what would come next.
Admin
Sure I have. Then I went and showered for 3 hours to scrub the horrible feel off, and went online to buy $500 worth of Bad Code Offsets...
Admin
Me. I don't even understand what the coder is trying to do. Usually, the WTF has some kind of twisted logic, and I normally mentally translate unfamiliar code into one the coding languages I'm at least semi-familiar with, but this just doesn't make sense.
So: global $EmailAddress (etc) produces a preassigned global variable? Which is then assigned to another global $email variable, which if false (or null?) results in another preassigned global variable, and so on? What's the point?
Admin
You mean something like:
And it's actually a feature, see perldoc exporter:
Admin
... Anyone who gives a damn about their codebase. If I'm working on a project and I find out that $EmailAddress and $emailAddress are both in use for the same thing, I fix it.
This code snippet indicates that either the author doesn't give a damn about the codebase, or there's some awful reason that $emailAddress can't be globally replaced with $EmailAddress, even though per the code snippet they are all apparently supposed to contain the email address.
And I do mean an awful reason. Try to think of a good coding decision that would lead to being unable to replace all the variant capitalizations of $EmailAddress with one consistent version. I'd love to hear it.
Admin
I tend to use them when I feel that I've made a class that is descriptive enough that there is very little value I can add by messing with the variable name too much. For example, in a recent project, I made a class called AssemblyTokenizer. I'm fairly certain that I declared it with...
AssemblyTokenizer assemblyTokenizer = new AssemblyTokenizer();
...because I felt that naming the object "sourceTokenizer" or "tokenizer" or something was just a slightly silly and unnecessary abstraction.
I dunno. I'm not a case-sensitive diehard, but it is a nice feature.
Admin
Admin
I was about to post a comment about how PHP is case-insensitive anyway, but having tried it, it seems that variable names in PHP are case-sensitive. Functions in PHP are case-insensitive; hell, even keywords like "if" are case-insensitive. But variables are case-sensitive.
What the hell, PHP?
Admin
I use a language which doesn't mind about cases, and an IDE that will normalise the case to the version used in the declaration.
TRWTF is languages that think i and I are different variables
Admin
In PHP, global essentially gives you a local access to a global variable. Hence, this code is searching for the right global variable among different naming conventions.
If you use conventions right, this just doesn't happen, but who actually does that?
Admin
at least it's not emailAddre$$
CAPTCHA: quis (This is making me quis-e, seeing all the combinations)
Admin
Just so everyone knows, if this is PHP, which it looks like it is, there is no case sensitivity. So $Email and $email are the same variable, etc.
Admin
Here is an argument. It forces the programmer to use the same capitalizations whenever a name is used. Thus information that may be conveyed through case, such as what kind of thing the name represents (whether it be a variable, function, macro, or template parameter), or the starts of words when using camel case, will be visible wherever that name appears.
Admin
This is perfectly standard, and perfectly readable. One is a class, the other is an object. No Java programmer would have a problem reading this.
Admin
I had to do something like this a couple times, but I encapsulated it into a function to get the ugly into it's own corner and out of the way of the rest of the code. Though since this screams PHP, I would have suggested using an array of names for variables, a foreach over those and the oh so hated variable variable names. It's already a klutz, might at least use a halfway elegant klutz to rescue you yourself from these kind of things.
Admin
I would wager that the 'email address' is incorrectly defined (i.e. different casing) in various places around the code and this is some sort of attempt to 'mung' them all together in some horrible way.
That or they were completely mad (or being paid by the line).
Admin
Imagine the job security.
Imagine the infamy as junior dev after junior dev saw our magnificent code and posted it the TDWTF
I'm going to start on such a language tonight. I'll call it SR. No: SR++
Admin
Yay! Go VB.Net!
Admin
Let me guess - classic BASIC? That's hard core, d00d. You use the line numbers and everything, huh?
Admin
print "$email\n";
Admin
global (in PHP) imports a potentially previously assigned global variable into the local scope. You can't use a global variable without using the global keyword. In more modern PHP you would use $GLOBAL['<var>'] though, which is always defined.
The code checks if different global variables were defined before and uses the first one it finds.
Admin
Case sensitive is good. It's kind of annoying when Initialize and initialize is the same name for everyone except people in Turkey.
Admin
Because then I can do things like this:
private int myInt; public int MyInt { get { return myInt; } set { myInt = value; } }
Now I can easily tell whether or I'm using the property (MyInt) accessed through the getter and setter (which may do other things - especially notifications for binding in the setter) or the backing field (myInt).
I know other people prefer to start their backing fields with an underscore, but I've never liked the way that looks.
Admin
I haven't done much work in PHP, but I'm pretty sure recent versions have a coalesce operator.
Admin
For those not believing that varialbes are casesensitive in PHP: http://php.net/manual/en/language.variables.basics.php First line reads: "Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive."
And because I just wanted to do it for kicks here my approach to this kind of thing whichi actually runs in a fightiningly large application. It also has comments for why this was done and even a reference to each of the places that would need changing if this was removed, just in case someone gets a bit stir crazy.
Enjoy
Admin
Compiles faster. No, really.