• (disco)

    Article's taking forever to load, but what I have so far is already bad enough.

    "The Helpful Customer"

    Sven built a PHP-based

  • (disco)

    I'm not familiar with the colon/semicolon syntax used with the if/else there...maybe that's a good thing...

  • (disco)

    If the thing, then write the other thing, otherwise write the same other thing? Oh right, you're supposed to just write the other thing, and comment out the old code!

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    commentake out the old code!
    PTFY
  • (disco) in reply to Fox
    Fox:
    PTFY

    :baby:: Isn't that the same thing?

  • (disco) in reply to Tsaukpaetra

    Touche, salesman....

    http://profile.ak.fbcdn.net/hprofile-ak-snc4/50275_273661609890_4349486_n.jpg

  • (disco)

    So it's also looking at a different variable?

  • (disco) in reply to Zemm

    A variable which does the opposite of the other one, apparentlyI hope.

  • (disco) in reply to Fox
    Fox:
    Article's taking forever to load, but what I have so far is already bad enough.

    "The Helpful Customer"

    Sven built a PHP-based

    Even better, "PHP-based" is unicorns and rainbows.

    Filed under: Of all the places to put the link...

  • (disco)
    Remy:
    Frankly, I'm surprised at the number of "if condition, do X else do X" submissions we get.

    I'm surprised that you're surprised...

  • (disco) in reply to LB_

    I had a moment of I didn’t know you could do that!

    LB_:
    I'm not familiar with the colon/semicolon syntax used with the if/else there...maybe that's a good thing...

    I share your sentiment. I haven't seen alternate PHP syntax in the wild for more than five years, if ever. They kept it in PHP 7, so it can't be wholly irrelevant though.

  • (disco)

    I think we're lucky that the condition body didn't contain the entire HTML form, best with tons of ECMAScript.

  • (disco) in reply to gleemonk

    I use it as a (poor man's) templating language.

        <ul>
            <?php foreach($links as $title => $url): ?>
                <li><a href="<?= $url ?>"><?= $title ?></a></li>
            <?php endforeach; ?>
        </ul>
    

    To me it's clearer to end the loop with endforeach, especially when there's a lot of HTML to print.

  • (disco) in reply to PJH
    PJH:
    Remy:
    Frankly, I'm surprised at the number of "if condition, do X else do X" submissions we get.

    I'm surprised that you're surprised...

    Well, what is the number? Is he surprised that it's so low or so high?

  • (disco) in reply to Wukl
    Wukl:
    I use it as a (poor man's) templating language.

    :scream: using PHP for its original purpose.

    Wukl:
    To me it's clearer to end the loop with endforeach, especially when there's a lot of HTML to print.

    I agree that under those circumstances an explicit endforeach is clearer than a mute }.

  • (disco) in reply to gleemonk

    I think WordPress still uses it and actively promotes it in their development guides. Saying that, the PHP code in WordPress is pretty shocking in a lot of places, so I'm not surprised they're using this awful syntax.

  • (disco)

    Dare I ask at what point if($can_submit) got changed to if(!isset($a3))?

  • (disco) in reply to Ashley_Sheridan
    Ashley_Sheridan:
    the PHP code in WordPress is pretty shocking in a lot of places

    FTFY

  • (disco) in reply to LB_

    Yeah, I was only familiar with the {} syntax. But I'd put the spacing and indentation in the PHP, not in the output...

    <?php
    if ($can_submit) {
        ?><button>Submit</button><?php
    }
    ?>
    

    Or... for a bit of HTML that small, I'd probably just use echo.

  • (disco) in reply to anotherusername

    Razor syntax (ASP.NET MVC) is so much cleaner:

    @if (CanSubmit)
    {
        <button>Submit</button>
    }
    
  • (disco) in reply to RaceProUK

    Fuck ASP though. Can it even handle file uploads natively yet?

  • (disco) in reply to anotherusername

    It's not ASP, it's ASP.NET.

    ASP is like [image]

    ASP.NET is more [image]

  • (disco)

    ... I actually know a thing or two about PHP.

    Danger, Will Robinson! Danger!

  • (disco) in reply to RaceProUK
    RaceProUK:
    It's not ASP, it's ASP.NET.

    It's a newer, upgraded version of ASP, and that doesn't really answer the question I asked.

  • (disco) in reply to anotherusername

    That's like saying Windows 10 is an upgraded version of MS-DOS.

    And yes, ASP.NET can handle file uploads natively.

  • (disco) in reply to RaceProUK

    Good to know, I guess. My experience with ASP was when my college gave us free web space and only allowed ASP. While PHP lets you handle an uploaded file, no problem, everything on the internet for doing that in ASP was "purchase and install this or that third-party addon"...

  • (disco) in reply to anotherusername

    My first job was with ASP, and I'll be among the first to claim that it's a total shitbag. Thankfully, within two years, I was working in ASP.NET (first WebForms, now MVC).

    I'd rather commit seppuku than go back to classic ASP :smile:

  • (disco)

    Yes, ASP.NET can handle file uploads. Both WebForms and MVC handle them just fine. Source: me. I built plenty of sites with those fuckers, and it's always a pain when a user has to go through a multi-step process and the user has to upload a file at step 2.

    And ontopic: this isn't too much of a WTF. The customer clearly said he "knows a thing or two about PHP" and he was able to solve the problem he was facing. For a non-programmer, I think he did a fairly good job. He probably looked at a different place where the if construct was used (or Googled it) and based his work off of that.

    Kudos to the guy for not accidentally breaking stuff because he missed a ?> or forgot to remove some brace, which would completely break his page.

  • (disco) in reply to RaceProUK

    ASP: http://media-2.web.britannica.com/eb-media/30/142430-004-C938E404.jpg

  • (disco) in reply to RaceProUK

    Until you do something it doesn't like with the spacing, and it can't decide which {}s are code and which are HTML.

    That's my main beef with ASP.NET MVC. Well, that and the routing. Good luck figuring out why you can't hit your methods if the magic stuff doesn't work the way you expected.

  • (disco) in reply to ufmace
    ufmace:
    Until you do something it doesn't like with the spacing, and it can't decide which {}s are code and which are HTML.
    I find it only gets confused when you don't tag a keyword you should have tagged with `@`.
    ufmace:
    Well, that and the routing. Good luck figuring out why you can't hit your methods if the magic stuff doesn't work the way you expected.
    Until you realise it's normally because you got the order of the routes wrong ;)
  • (disco) in reply to ufmace
    ufmace:
    Well, that and the routing.

    Routing seems to be the normal problem with web frameworks. The order of the day with them appears to be almost always to tend towards being highly confusing…

    I'm not sure that there's much that can be done about it other than adding some probably-even-more-confusing routing compiler to the mix.

  • (disco) in reply to PJH
    PJH:
    Remy:
    Frankly, I'm surprised at the number of "if condition, do X else do X" submissions we get.

    I'm surprised that you're surprised...

    Same here. It appears that "if condition, do X else do X" is a terribly a difficult concept for some "programmers.". Right up there with all those impossible-to-understand arrays.

    ,,,and indexes in database systems...and Boolean values.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    PJH:
    Remy:
    Frankly, I'm surprised at the number of "if condition, do X else do X" submissions we get.

    I'm surprised that you're surprised...

    Same here. It appears that "if condition, do X else do X" is a terribly a difficult concept for some "programmers.". Right up there with all those impossible-to-understand arrays.

    ,,,and indexes in database systems...and Boolean values.

    Sometimes I do that with TODO comments and logging in either the if logic or the else logic as one of them requires components/controls/modules that is not done yet and I do not wish to break the program flow. But knowing some of my previous coworkers, they have the habit of removing my TODO comments and not implementing anything leaving me confused when I come across my own WTF.

  • (disco) in reply to jkshapiro
    jkshapiro:
    Dare I ask at what point if($can_submit) got changed to if(!isset($a3))?

    Bob was trying things at random to get the button to show all the time. The "can_submit" function was just too much indirection for a brain to handle so he removed it and replaced it with its contents ("What's the point of a function that only has one line in it? That's a bit wasteful of resources"). And having done it, it was: "Right, now let's see how to get it to make sure that a3 is set all the time."

    Took him a while to realise that he could use the "else" concept, by which time he had forgotten what the "isset($a3)" was actually for, and left it in just in case "isset" actually had side-effects that changed stuff.

  • (disco)

    When someone asks me "how do I do X?" (especially in PHP), and it's shortly followed by "Never mind, I figured it out myself." I know I don't really want to know how they figured it out.

  • (disco) in reply to Matt_Westwood

    That was painful to read. I'm sorry.

  • (disco) in reply to Fox

    Just read the preview again:

    “You won’t be getting a lot of support calls from me,” Bob said, “because I actually know a thing or two about PHP. I’ll be maintaining this myself.”

    Considering this, I expected something like a Code Zombie Apocalypse. Under this aspect, that if-instruction-else-sameinstruction construct is like a rotten slice of sausage in comparison.

  • (disco) in reply to PWolff

    “You won’t be getting a lot of support calls from me,” Bob said, “because I actually know a thing or two about PHP. I’ll be maintaining this myself.”

    I know a thing or two about medicine - I'll be taking care of your health care for the next few years...or maybe less.

  • (disco)

    So.. The client wants the submit button to appear all the time so he adds conditions to the already existing conditions? How about REMOVING THE CONDITIONS?

    "I know a thing or two about PHP.." That should've rang a bell.. like a wedding in church .. with the trumpets of Jericho..

  • (disco) in reply to dkf
    dkf:
    Routing seems to be the normal problem with web frameworks. The order of the day with them appears to be almost always to tend towards being highly confusing…

    I'm not sure that there's much that can be done about it other than adding some probably-even-more-confusing routing compiler to the mix.

    I'd like to see an equivalent to the Rails rake routes command that lists all of the routes in the app, what the URL, request type, and options are, and what controller and method it connects to. As it is now, if your routes aren't working the way you expect, there doesn't seem to be any way to debug what's going on, and you just have to guess and stab in the dark until it works.

    Seems like a strange world when C# is using more incomprehensible magic than Ruby.

  • (disco) in reply to ufmace
    ufmace:
    if your routes aren't working the way you expect, there doesn't seem to be any way to debug what's going on

    This is why magic is bad. In many frameworks in various languages, you specify in code what route maps what url to what controller and method. Thus, you can find and debug it easily when there's a problem.

  • (disco) in reply to Yamikuronue

    We mostly end up using the attribute routes in MVC, which is pretty much the same thing. About half of the headaches are from the auto-routes based on the controller and method, and the other half are from the too-smart-for-its-own-good attempts to map any kind of POST param to some kind of object, and to reject the route entirely if it can't figure out how to map whatever you POSTed at it to whatever the type of the method's parameter is, again with nothing helpful to debug.

    Not sure if I'd say all magic is bad, but you should at least be able to debug into the magic and have clear options to override it when it doesn't do what you need.

  • (disco) in reply to PJH

    If people don't even understand those simple IF-THEN-ELSE constructs, then how shall they understand those with FILE_NOT_FOUND?

  • (disco) in reply to dkf
    dkf:
    Routing seems to be the normal problem with web frameworks. The order of the day with them appears to be almost always to tend towards being highly confusing…

    This is one of the reasons why I generally dislike web frameworks (and hence got out of web development and hope to never go back). As far as I'm concerned, there's already a perfectly good framework for this routing stuff, with fancy Web 2.0 (TM) names like "web server" and "file system".

  • (disco) in reply to gleemonk
    gleemonk:
    I share your sentiment. I haven't seen [alternate PHP syntax][1] in the wild for more than five years, if ever. They kept it in PHP 7, so it can't be wholly irrelevant though.
    From the link:
    Warning Any output (including whitespace) between a switch statement and the first case will result in a syntax error. For example, this is invalid:
    ``` <?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?> ```
    Belgium­ing Discourse. Continued::
    Whereas this is valid, as the trailing newline after the switch statement is considered part of the closing ?> and hence nothing is output between the switch and case:
    ``` <?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?> ```

    Really, PHP? :wtf: is wrong with you?

  • (disco) in reply to Dreikin
    Dreikin:
    Really, PHP? :wtf: is wrong with you?

    Isn't it simpler to ask what isn't wrong with PHP?

    I'm asking for @arantor.

  • (disco) in reply to Dreikin

    Poor man's templating language integrated with main language + syntax. It continues to be one of the most retarded parts of PHP.

  • (disco) in reply to FrostCat

    It does get enough things right that it outpaced Perl for running sites, is generally quite sandboxed and predictable in its behaviour.

    The problem is knowing all 3,742 gotchas to explain what that behaviour will be.

  • (disco)

    So...

    if(condition_is_met)
       do_Stuff();
    else
      do_Stuff();
    

    Ingenious!

Leave a comment on “The Helpful Customer”

Log In or post as a guest

Replying to comment #461542:

« Return to Article