• grizz (unregistered) in reply to Slink
    Slink:
    grizz:
    Richard T. Roll:
    I've used this a lot in my programming career and I know some might disagree but tbh it's just a different approach.

    I've used cannibalism a lot in my food-procuring career and I know some might disagree but tbh it's just a different approach.

    Sometimes "bad" really is bad, not just different.

    You were writing that as a reply to a post made by Richard T.Roll... Sarcasm detector offline? ;) Or am I the one missing that sarcasm tag in your reply?

    Could be my sarcasm detector was still using a config from lastlastyear. ;-) If so, sorry!

  • Downfall (unregistered) in reply to toth
    toth:
    Well, on embedded systems like Bessy, it's much more efficient to unroll the loop. Paula Bean taught me that.

    Agreed. If there's no file system to store a calendar, you do what you gotta do. It's not pretty, but it works and is fairly standard practice.

  • neveralull (unregistered)
    <?php $todaysBreakfast="spam" $yesterdaysBreakfast="spam,spam"; $dayBeforeYesterdaysBreakfast="spam,spam,spam"; $dayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam"; $dayBeforeTheDayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam,spam,spam"; $dayBeforeTheDayBeforeTheDayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam,spam,spam,eggs,bacon,and spam"; ?>
  • Squidfood (unregistered)

    That's something like the optimistic document-naming convention we use when passing edits around:

    Specs-final.txt Specs-final-final.txt Specs-final-final-edits.txt Specs-final-final-final.txt Specs-ReallyTrulyfinal-final.txt Specs-ReallyTrulyfinal-final-v2.txt

  • anonanonanonanonanonanonanonanon (unregistered) in reply to Techpaul
    Techpaul:
    Don't even get me on the inability of some hosting companies, to understand the differences between even Windows and Linux.

    go on, you've sparked my interest with that

  • jira was never this fun (unregistered)

    hahahahaha

  • Flakeloaf (unregistered) in reply to MetalPig
    MetalPig:
    toth:
    Paula Bean taught me that.
    Isn't she on the same network as Rachael Array?

    I liked her in The Matrix.

  • Blue Collar (unregistered)

    The new Epoch and Y2K is now when that variable name gets too long that the compiler can't support it!

    CAPTCHA Similis: Each line of that code was similis to the previous...

  • (cs) in reply to Tim
    Tim:
    ah, a good old fashioned 100% bad code indefensible WTF (and using PHP into the bargain)

    this is what we like to see

    Nothing wrong with PHP per se (you can write a WTF in any language), but this is pure butchery.

  • Jay (unregistered)

    The problem here is field names that are insufficiently descriptive. A much better approach would be:

    <?php
    $thisyear=date("Y");
    $cuttofYearForAccounting=date("Y")-1;
    $lastYearForAutomaticRollback=date("Y")-2;
    $yearWeAcquiredFoobarSubsidiary=date("Y")-3;
    $yearWeStartedThisProject=date("Y")-4;
    $yearMyCousinBernieGotMarried=date("Y")-5;
    $yearBobMadeThatDumbMistakeAndCrashedTheBackupServer=date("Y")-6;
    $yearWTFIntroducedIrishGirl=date("Y")-7;
    $yearHitchhikersGuideWasPublished=date("Y")-42;
    ?>
    

    Etc.

  • u4 (unregistered) in reply to grizz
    grizz:
    Slink:
    grizz:
    Richard T. Roll:
    I've used this a lot in my programming career and I know some might disagree but tbh it's just a different approach.

    I've used cannibalism a lot in my food-procuring career and I know some might disagree but tbh it's just a different approach.

    Sometimes "bad" really is bad, not just different.

    You were writing that as a reply to a post made by Richard T.Roll... Sarcasm detector offline? ;) Or am I the one missing that sarcasm tag in your reply?

    Could be my sarcasm detector was still using a config from lastlastyear. ;-) If so, sorry!

    I think Slink's sarcasm detector is only half operational anyway... Dick T.Roll

  • Enterprise Architect (unregistered) in reply to u4
    u4:
    grizz:
    Slink:
    You were writing that as a reply to a post made by Richard T.Roll... Sarcasm detector offline? ;) Or am I the one missing that sarcasm tag in your reply?

    Could be my sarcasm detector was still using a config from lastlastyear. ;-) If so, sorry!

    I think Slink's sarcasm detector is only half operational anyway... Dick T.Roll

    I think I know his brother. Any relation to Toot C. Roll?

  • moz (unregistered) in reply to jonsjava
    jonsjava:
    You see, you grab a random equation, and apply it randomly across the board, and you get the same results, while having crazy code. Job Security.
    Odd way of doing things. I'd prefer just to demonstrate that I have actually heard of loops:
    <?php
    $thisyear = $year = date('Y');
    foreach(range(0, 6) as $_) {
        ${str_repeat('last',$_+1).'year'} =
            ${str_repeat('last,$_).'year'}-1;
    }
    unset($year);
    ?>
    

    The rest of the code would, of course, remain as is.

  • ARMed but harmless (unregistered)

    Maybe it's my limited knowledge of the English language, but I found the following gem quite enlightling:

    Business 'customers' would define requirements (or bugs), business analysts would write requirements to implement those
  • *Legion* (unregistered) in reply to java.lang.Chris;
    one of the leading guys working on improving the stability and security of the code quit in disgust at the unwillingness of Zend to accept changes.

    Which leading guy was that?

  • //Rumen (unregistered) in reply to Slink

    ..... stupid spam system...

  • mh (unregistered) in reply to ARMed but harmless
    ARMed but harmless:
    Maybe it's my limited knowledge of the English language, but I found the following gem quite enlightling:
    Business 'customers' would define requirements (or bugs), business analysts would write requirements to implement those
    Sounds like standard operational procedure in a lot of places to me.
  • JimmyMcJimbo (unregistered) in reply to Marius
    Marius:
    And did you have any 120 years old visitors on that site? I'm curious.

    When on any site that i have to input DOB but dont have to register, i always choose the oldest date possible.

    verto - Vertical spaghetti-oh's,

  • Bub (unregistered)

    Shovel-ready code

  • //Rumen (unregistered) in reply to Enterprise Architect
    Enterprise Architect:
    u4:
    grizz:
    Slink:
    You were writing that as a reply to a post made by Richard T.Roll... Sarcasm detector offline? ;) Or am I the one missing that sarcasm tag in your reply?

    Could be my sarcasm detector was still using a config from lastlastyear. ;-) If so, sorry!

    I think Slink's sarcasm detector is only half operational anyway... Dick T.Roll

    I think I know his brother. Any relation to Toot C. Roll?

    Here's his profile: http://en.wikipedia.org/wiki/Rickrolling

    I would post the link, but Askimet is being a douchebag...

  • Outtascope (unregistered) in reply to Jay
    Jay:
    $yearHitchhikersGuideWasPublished=date("Y")-42;
    

    Ahem,

    $yearHitchhikersGuideWasPublished=date("Y")-31;
    

    But thanks for the momentary panic caused by thinking that I may have lost a decade.

  • Ouch! (unregistered) in reply to forgottenlord
    forgottenlord:
    When I took a new job at a small company, I knew the processes wouldn't be a little more 'casual', but I never quite expected this. Even the code is written casually,

    "Wouldn't be a little more 'casual'? But then....how is the code casual if it wouldn't be more casual? </pedantic-bastard>

    Sheesh.

  • A. Cube (unregistered)

    This is bad (indefensibly bad), but the sad thing? I have seen worse, much worse.

  • (cs) in reply to APK
    APK:
    TRWTF is the lack of underscores. It should be "$last_last_last_last_year" which is much more readable and maintainable.

    This is PHP. It should be:

    $last_year $last_last_year $lastLastLastYear $last_last_last_last_year $lastLastLastLastLastYear

  • ClaudeSuck.de (unregistered) in reply to frits
    frits:
    Geez, don't they realize the numberline goes in two directions?
    <?php
    $thisyear=date("Y");
    $lastyear=date("Y")-1;
    $lastlastyear=date("Y")-2;
    $lastlastlastyear=date("Y")-3;
    $lastlastlastlastyear=date("Y")-4;
    $lastlastlastlastlastyear=date("Y")-5;
    $lastlastlastlastlastlastyear=date("Y")-6;
    $lastlastlastlastlastlastlastyear=date("Y")-7;
    $nextyear=date("Y")+1;
    $nextnextyear=date("Y")+2;
    $nextnextnextyear=date("Y")+3;
    $nextnextnextnextyear=date("Y")+4;
    $nextnextnextnextnextyear=date("Y")+5;
    $nextnextnextnextnextnextyear=date("Y")+6;
    $nextnextnextnextnextnextnextyear=date("Y")+7;
    ?>

    That's a lot nicer:

    <?php $thisyear=date("Y"); $lastyear=date("Y")-1; $lastlastyear=date("Y")-2; $lastlastlastyear=date("Y")-3; $lastlastlastlastyear=date("Y")-4; $lastlastlastlastlastyear=date("Y")-5; $lastlastlastlastlastlastyear=date("Y")-6; $lastlastlastlastlastlastlastyear=date("Y")-7; $nextnextnextnextnextnextnextyear=date("Y")+7; $nextnextnextnextnextnextyear=date("Y")+6; $nextnextnextnextnextyear=date("Y")+5; $nextnextnextnextyear=date("Y")+4; $nextnextnextyear=date("Y")+3; $nextnextyear=date("Y")+2; $nextyear=date("Y")+1; ?>

    Much more readable, I say

  • (cs)

    And this is why good (or aspiring) developers should avoid small companies like the plague unless it's new, hip startups. Inevitably the existing code will have been written by some hack with no car or knowledge how to properly write software; typically somebody who "knows MS Access" or "worked with Foxpro years ago" and taught themselves VBScript/PHP in a couple of days.

    95% of small businesses are career killers.

    Addendum (2010-02-17 15:34): meant "career", not car, of course.

  • php (unregistered)
    $name = 'lastyear';
    $year = date('Y');
    while (($$name = --$year) > 2005)
        $name = 'last' . $name;

    You are welcome, gentlemen.

  • ClaudeSuck.de (unregistered) in reply to neveralull
    neveralull:
    <?php $todaysBreakfast="spam" $yesterdaysBreakfast="spam,spam"; $dayBeforeYesterdaysBreakfast="spam,spam,spam"; $dayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam"; $dayBeforeTheDayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam,spam,spam"; $dayBeforeTheDayBeforeTheDayBeforeTheDayBeforeYesterdaysBreakfast="spam,spam,spam,spam,spam,spam,eggs,bacon,and spam"; ?>

    Lemmon Curry?

  • (cs) in reply to ObiWayneKenobi
    ObiWayneKenobi:
    And this is why good (or aspiring) developers should avoid small companies like the plague unless it's new, hip startups. Inevitably the existing code will have been written by some hack with no car or knowledge how to properly write software; typically somebody who "knows MS Access" or "worked with Foxpro years ago" and taught themselves VBScript/PHP in a couple of days.

    95% of small businesses are career killers.

    Why does it matter if he has a car?

  • Enterprise Architect (unregistered) in reply to php
    php:
    $name = 'lastyear';
    $year = date('Y');
    while (($$name = --$year) > 2005)
        $name = 'last' . $name;
    This… this is what is wrong with PHP.
  • ClaudeSuck.de (unregistered) in reply to blakeyrat
    blakeyrat:
    ObiWayneKenobi:
    And this is why good (or aspiring) developers should avoid small companies like the plague unless it's new, hip startups. Inevitably the existing code will have been written by some hack with no car or knowledge how to properly write software; typically somebody who "knows MS Access" or "worked with Foxpro years ago" and taught themselves VBScript/PHP in a couple of days.

    95% of small businesses are career killers.

    Why does it matter if he has a car?

    If you live in a VAN close to the river...

  • (cs)

    Woohoo! FirstFirstFirstFirstFirstFirstFirstFirstFirstFirst(...etc...) Post!

  • MP(Real) (unregistered)

    I've seen the lastlastlastlast... style of programming implemented in C and of course LISP.

    PHP is great for what it does, but bad Java, C#, etc programmers (or typically just C-wannabe programmers) always complain about it because they fear for their job security. A bad PHP programmer can get things done much faster than a bad <insert other language> programmer.

    In the end, good programmers are good at writing programs with C and LISP (and related languages). Additionally, good programmers can handle languages like PHP without doing silly things.

  • Sinan Unur (unregistered) in reply to frits

    Here is an improvement:

    <?php
                                        $thisyear=date("Y");
                            $nextyear=date("Y")+1;$lastyear=date("Y")-1;
                        $nextnextyear=date("Y")+2;$lastlastyear=date("Y")-2;
                    $nextnextnextyear=date("Y")+3;$lastlastlastyear=date("Y")-3;
                $nextnextnextnextyear=date("Y")+4;$lastlastlastlastyear=date("Y")-4;
            $nextnextnextnextnextyear=date("Y")+5;$lastlastlastlastlastyear=date("Y")-5;
        $nextnextnextnextnextnextyear=date("Y")+6;$lastlastlastlastlastlastyear=date("Y")-6;
    $nextnextnextnextnextnextnextyear=date("Y")+7;$lastlastlastlastlastlastlastyear=date("Y")-7;
    ?>
    
  • (cs) in reply to *Legion*
    *Legion*:
    one of the leading guys working on improving the stability and security of the code quit in disgust at the unwillingness of Zend to accept changes.

    Which leading guy was that?

    Stefan Esser. See the following Register article for more info: http://www.theregister.co.uk/2006/12/21/php_security_scrutinised/

    (And the Akismet thing that this site uses sucks donkey balls).

  • rfoxmich (unregistered)

    This is just a shop that paid by the KLOC.

  • AndrewH (unregistered)

    Meh. The article even says in the first paragraph that the flaws in PHP programs are generally the fault of developers, rather than the language. They list SQl injection, XSS, and file inclusions as the major flaws. That's just dumb developers.

    PHP has problems (only just now getting namespaces and late static binding, messy standard function library, etc). But the problems it has don't correlate to the things people blame it for. This developer didn't understand loops. That's not a PHP thing, that's not understanding basic programming. The doofus who wrote this would have implemented it the same in C, Java or Fortran.

  • Rynus_Rein (unregistered)

    Looks similar to a snippet from an 'internet' company (PHP) I once worked for. In the user control panel of a guestbook service, users could delete 10, 20, 50, 100, 200 or 500 messages at once. It was literally implemented like:

    if ($nr == 10) { $q = "DELETE FROM message WHERE UserId=" . $id . " LIMIT 10"; } if ($nr == 20) { $q = "DELETE FROM message WHERE UserId=" . $id . " LIMIT 20"; } if ($nr == 100) { $q = "DELETE FROM message WHERE UserId=" . $id . " LIMIT 100"; }

    and so on :-). Actually, I managed to keep working there for almost 2 years...

  • Real Pedantic Bastard (unregistered) in reply to forgottenlord
    forgottenlord:
    When I took a new job at a small company, I knew the processes wouldn't be a little more 'casual', but I never quite expected this. Even the code is written casually,

    <pedantic-bastard>"Wouldn't be a little more 'casual'? But then....how is the code casual if it wouldn't be more casual? </pedantic-bastard>

    FTFY.

  • (cs) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    That's a lot nicer: <?php $thisyear=date("Y"); (snip) $lastlastlastlastlastlastlastyear=date("Y")-7; $nextnextnextnextnextnextnextyear=date("Y")+7; (snip) $nextyear=date("Y")+1; ?>

    Much more readable, I say

    No, no, no, no. You've got it all wrong. This is clearly the way to go:

    <?php 
      $lastlastlastlastlastlastlastyear=date("Y")-7; 
        $lastlastlastlastlastlastyear=date("Y")-6; 
          $lastlastlastlastlastyear=date("Y")-5; 
            $lastlastlastlastyear=date("Y")-4; 
              $lastlastlastyear=date("Y")-3; 
                $lastlastyear=date("Y")-2; 
                  $lastyear=date("Y")-1; 
                   $thisyear=date("Y"); 
                  $nextyear=date("Y")+1; 
                $nextnextyear=date("Y")+2; 
              $nextnextnextyear=date("Y")+3; 
            $nextnextnextnextyear=date("Y")+4; 
          $nextnextnextnextnextyear=date("Y")+5; 
        $nextnextnextnextnextnextyear=date("Y")+6; 
      $nextnextnextnextnextnextnextyear=date("Y")+7; 
    ?> 

    Not only do the lines earlier in time come first, it's arranged in the only sane way time-related code can be arranged.

  • (cs)
    I knew the processes wouldn't be a little more 'casual'...

    I think that word probeily doesn't mean what you think it means.

  • Techpaul (unregistered) in reply to anonanonanonanonanonanonanonanon
    anonanonanonanonanonanonanonanon:
    Techpaul:

    Don't even get me on the inability of some hosting companies, to understand the differences between even Windows and Linux.

    go on, you've sparked my interest with that

    First mentioned in Network Batch File virus comments see comment 297392

    http://thedailywtf.com/Comments/Classic-WTF-The-Network-Batch-File-Virus.aspx?pg=2#297392

    Basically moved customer website and database between servers WITHOUT TELLING THE CUSTOMER that were originally Linux/Apache to Windows/IIS Server and did not check if things like .htaccess or version control etc.. would cause any problems.

    Obviously as a web hosting company that took over another, the new company only understood windows.

  • Sou Eu (unregistered)
    I knew the processes wouldn't be a little more 'casual', but I never quite expected this. Even the code is written casually,

    Methinks there's a typo in the article.

  • Cliff Wells (unregistered) in reply to PHPGangsta
    PHPGangsta:
    Last week I wrote code to display a drop-down-field for birthday, with the last 120 years (1890-2010). That was done with a few (~5 or so) lines of code.

    Would be interesting to see this in your notation. Great code example!

    Exactly what user ever wants to interact with a drop down that's over a foot long? It might surprise most developers that even the saddest luser can often type in the four digits of their birth year (some of them even have it memorized).

  • Montoya (unregistered) in reply to Voodoo Coder

    If you want stuff like that, look at Ruby on Rails.

  • (cs) in reply to me
    me:
    what are the odds that the probeility of the month being frebruary?
    I've seen a lot of people misspell "February", but that's a new one.
  • Anonymous Guy (unregistered)
    <southpark>

    By our calculations, we predict global warming will hit...

    Two days before the day after tomorrow

    </southpark>
  • My Name (unregistered) in reply to Pidgeot
    Pidgeot:
    No, no, no, no. You've got it all wrong. This is clearly the way to go:
    <?php 
      $lastlastlastlastlastlastlastyear=date("Y")-7; 
        $lastlastlastlastlastlastyear=date("Y")-6; 
          $lastlastlastlastlastyear=date("Y")-5; 
            $lastlastlastlastyear=date("Y")-4; 
              $lastlastlastyear=date("Y")-3; 
                $lastlastyear=date("Y")-2; 
                  $lastyear=date("Y")-1; 
                   $thisyear=date("Y"); 
                  $nextyear=date("Y")+1; 
                $nextnextyear=date("Y")+2; 
              $nextnextnextyear=date("Y")+3; 
            $nextnextnextnextyear=date("Y")+4; 
          $nextnextnextnextnextyear=date("Y")+5; 
        $nextnextnextnextnextnextyear=date("Y")+6; 
      $nextnextnextnextnextnextnextyear=date("Y")+7; 
    ?> 

    Not only do the lines earlier in time come first, it's arranged in the only sane way time-related code can be arranged.

    This has to be my favourite, it's arranged chronologically AND it looks like an hourglass. It works on so many levels!

  • cfreak (unregistered) in reply to jonsjava
    jonsjava:
    Anon:
    ... I mean, this is php after all.

    PHP isn't a bad scripting language. It's just that 99% of the PHP coders give the rest of us a bad name. I use it for server-side coding (both windows/linux) when I need a script to do something, and I don't have the time to build a real app. Handy little system in a pinch.

    As a user of both PHP and other languages I can say that PHP is a terrible language. There's no coherent design, they can't even decide what kind of language they want it to be. They say they want to be object oriented like Java, but it's done halfway (especially in 4, 5 is better). No standard classes. No multiple inheritance (though arguably that's a good thing)

    Then all the examples in the official documentation are procedural, something it's worse even worse at. Seriously do we need 20 some odd functions to manipulate an array? Is it really fun to type yet_another_long_ass_function_name()? Do we have to have low level database drivers, and other third party tools embedded into the language (with no real way of implementing proper security)

    Memory management is a mess. References (pointers) don't work right. There are random bugs in minor versions. There are multiple official add-ons to do the same stuff. Global variables for getting website request information (are named parameters too much to ask for?)

    There are workarounds for all the problems of course but there's not any good documentation. You have to dig through mountains of forums to find them and the official examples often give bad programming advice. PHP does create a low barrier to entry which is fine, but it throws security and basic programming design out the window and has created an army of horrible developers.

    PHP took the worst ideas from Java, Perl and C. Then they blended it together and called a language.

  • mos (unregistered) in reply to jonsjava
    jonsjava:
    I decided to improve the code to a degree:
    <?php
    $thisyear=date("Y");
    $math = round((($thisyear * 2) + 4) /2 - 2); 
    $lastyear=round((($math * 4) + 4) / 4 - 2);
    ...
    ?>
    

    Mutating an abomination ever further. Truly there is no magic in code, otherwise it would have opened a portal to the lower levels of hell.

Leave a comment on “Last, Last, Last, Last, Last, Last, Last Year”

Log In or post as a guest

Replying to comment #:

« Return to Article