- 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
$f.$i.$r.$s.$t.'?'
Admin
Every guru knows about job security
Admin
Guru and php is pretty much an oxymoron isnt it?
Admin
And this is why anyone who calls themselves a "guru" should be fired immediately. Nevermind that all of these stories that feature a so-called guru in Language X always ends up with the person writing shitty code.
Admin
Admin
I hope I don't get like that someday... :/
Admin
or you could simply not be a jackass and realize that any-non-zero value is considered true and a non-empty string is considered non-zero.
and then you could be even less of a dumb ass by realizing that you're trying to say the language is bad by demonstrating a misuse of the language
and then you could continue by realizing that most dynamically typed languages would behave the same
then you could look up the === operator (yes three ='s) in PHP
oh but i forgot.... it's the in thing here to bash PHP since it's the competitor to C# ASP/.NET.
PS: PHP isn't a bad language, it's however an EASY language - easy languages get a higher proportion of bad programmers.
Admin
Admin
'0' is a non-empty string, (bool)'0' evaluates to FALSE.
Admin
it also is the numeric value zero... a string which is comprised of only decimal digits is considered a number for all intents and purposes. it's a weakly typed language, get over it.
Admin
Way to confirm the irreplaceability of the guru.
Admin
Admin
I have the feeling I once had this deja vu experience of seeing some similar code...
Admin
Yes, '0' is non-empty; however, it is not non-zero.
Admin
he was pouncing on my generalize of non-empty strings being considered non-zero... because i simply didn't add "unless its contents are the number zero"
Admin
As someone whose main qualification is PHP, I can say that PHP is a bad language. It's a very bad language that can be written well if you try hard enough.
Admin
I once knew a programmer who would swear by his practice of prefixing all function names with A, B, C, depending on the order in which they executed in their main thread. If they called functions of their own, those would be named AA, AB, AC, BA, BB, BC, etc...
And if both A_Something and B_Other called a common function, you would end up with AA_BA_Helper. Or AA_Helper and BA_Helper both calling _SHARED_Helper.
Sometimes profanity would be spelled out in the prefixes (totally inadvertently, of course), and the function names also had a habit of not being particularly descriptive. Like Go, Do, Run, Filter, etc...
Of course, other programmers knew the stupidity of this system and ignored the prefixes, creating functions with identical names (just without the prefixes) or not adding extra prefixes to functions called by many. It was a nightmare of backtracking. By the time I got to it, I spent most of my time deleting duplicates and renaming everything. I actually doubled the speed of the application without changing a single line of 'meat' code.
Admin
Yup, that about covers all cases. Javascript's the same way. Annoying, yes, but it's not that hard to figure out... granted, anybody who is using a string value in a boolean context and NOT trying to implement some obfuscatedfullery ought to be... I don't know, <INSERT BAD HAPPENSTANCE HERE>.
Admin
The Real WTF is PHP for their stupid boolean evaluation, Ha! QED
Admin
I'm always impressed by the fact that people who say that PHP is a bad language, for it promotes odd inconvenient structures, is full of exceptions and incoherent rules, can be so readily abused, and therefore would and should be unpopular if it weren't for the great unwashed masses always choose to state those facts in English.
Admin
Better:
function happenstance($a, $b, $c) { "Select" .$a. " FROM " .$b. " " .$c; }
happenstance('f_name', 't_happenstances', 'LIMIT 0,1');
Admin
my main qualification is C++, i have written a lot of php code and was paid to write LAMP eCommerce apps for 18 months.. only thing i couldn't find a good solution for is the Call Super, which C++ also lacks a good solution to (hence I avoid anything useful that could come from a solution to call super)
Admin
This comment is brilliant, you know!
Admin
This is a primary example of "Job Security", or "Ease of understandability (well documented)". Looks like you only get to pick one.
A true "guru" will have both, and will not be self described.
Admin
Admin
Quoted for truth.
Titles like "elite" and "guru" are given, not taken. If other people aren't calling you The Man, you aren't (or at least, aren't yet).
Admin
Uh, dude? Check what site you're on -- ALL the stories here end up with people writing shitty code. (Or some sort of hardware/management failure.) If you heard that some guy was a code guru in Language X and checked his functions and they were awesome, your story would not be told here. You'll have to go to AwesomeCodeStoriesForAwesomeCodeGurus.com to find that sort of story. Or more likely you'll find a DNS error (or if your ISP is evil, a search page -- which ought to be punishable by death)
Admin
And if that's how you write English, I'm glad I've never run into your code.
Admin
... I'm always impressed by the fact that people who say that PHP is a bad language, for it promotes odd inconvenient structures, is full of exceptions and incoherent rules, can be so readily abused, and therefore would and should be unpopular if it weren't for the great unwashed masses always choose to state those facts in English. ...
And if that's how you write English, I'm glad I've never run into your code.
Stupid Muphry's Law.
Admin
Yes yes. PHP clearly sucks. That's why no major sites use it.
Or is it just that it's easy to get started with and thus we end up with lots of bad PHP code?
Admin
But it doesn't have to be the guru writing shitty code, it could be someone else in the story
Admin
An expert is anyone 40 miles from home. A guru is anyone you wish was 40 miles away.
Admin
that's exactly it - PHP is easy to learn.
Admin
This sounds like an old COBOL practice to me. I worked in a shop where 'goto considered harmful' so everything got performed...
A-MAIN performed B_INITIALIZE, C-LOOP and D-TERMINATE and so on down to lower levels. We always seemed to end up with a paragraph called GAY-ABANDON, innocent days.
Captcha: genitus. I'm almost afraid to ask...
Admin
You know, I've never understood the PHP-bashing. As an experiment, we wrote the same simple web app in Tomcat/Java, Python, and PHP. It took two weeks in Python - mostly fighting with the flash front-end. It took two days in PHP. And it took 5 days in Java.
Frankly, crying about the language just means you lost your juicy contract to someone who undercut you on a web project proposal. I would never use PHP for anything other than web coding, but it excels at simple web applications.
Admin
Admin
Ah, the old "I know what it means so it will always be good" syndrome. Not quite as bad as spaghetti code but pretty darn close.
I've had the dubious pleasure of re-writing a bunch of procedures as we upgrade and have had to deal with half a dozen temp tables at a time, each with a primary key field name of .. id.
I'd rant more but I'm the one who wrote them that way all those years ago. Now I can just shake my head and laugh. And be glad no one else has to deal with my stupidity.
Admin
/me wipes tears of laughter from his eyes. Can you not see the "Quote" button? How about the "Preview" button?
Now, let us go to Wikipedia and learn of this man "Muphry"!
Admin
Admin
Ok... and the problem is... ?
Admin
For those who bash PHP here, just note that this WTF could occur in just about any higher level language.
Admin
Although it's not my only language, it is the most frequently encountered at the workplace on a daily basis, and... I must disagree with you saying 'it can be written well if you try hard enough'
Any person with formal training in writing code, problem solving, and logic, can write correct and reliable code in PHP. It's not about trying hard enough. It's about good habits, code clarity, and consistency.
Each language has its rough spots, so don't be a noob and imagine yourself above PHP. Fanbois < crackheads
Admin
Admin
It's the way PHP handles form data that causes these issues. Everything is dumped into a nice array (even though php has terrible arrays) and then you get to work with the data from there.
Most higher-level languages make you do specific stuff on the back-end to process the data.
Admin
Ouch. Glad I don't write my PHP like that! Everyone knows the proper way to do things is:
function evaluate($args)
Called like:
evaluate(array( 'arg1' => 5, 'arg2' => 'sheep', 'arg3' => 'wtf' ));
Admin
Admin
I would say this is an incorrect conclusion. Because people shoot at other people with guns by accident, does not mean that this could not have been prevented/occurrences reduced by a brief 20 minute class on weapon safety. Of course, even if an individual took such a class, does not prevent them from shooting someone again. At this point in the story, I prefer strict typing in a language, and a ruthlessly critical compiler.
Admin
Yeah, or at least severe forms of torture. public DNS FTW.
Admin
Hey, are you also satanicpuppy on /. ?
Admin
Are you making fun of my name? That's not nice.