5
absurd
4y

fuck php and fuck it's whitespace header not sent bullshit, apparently there a bazillion ways the header function may just refuse to work, all for a function javascript does way better

Comments
  • 4
    how do you mess up headers, seriously?
  • 1
  • 6
    @absurd Don't be stupid and use headers_sent() to avoid quite literally all of these problems.
  • 1
    @PrivateGER I already fixed it. Also, a better solution would be if I just used javascript, instead.
  • 8
    Just a few notes here...

    PHP is a script language executed server side.

    JS is client side - and was meant to be executed by the browser... Well. Till they took it and decided it is clever to do everything in JS, wether it makes sense or not.

    The simple reason PHP behaves like it behaves is because it is an process directly outputting to the client - everything PHP outputs will be sent to the browser... and that is even explained by the stack overflow link.

    You're comparing two completely different languages with two conceptionally different behaviours.

    Maybe read a bit more about how HTTP works, how most webservers work.

    It should be obvious then that PHP makes perfect sense...

    And yes, there are many possibilities to prevent this.

    All in all... Please learn the basics. Not meant offensive, but from your rant I am pretty convinced that learning the basics will spare you a lot of pain and frustration.
  • 2
    @IntrusionCM "It should be obvious then that PHP makes perfect sense..." lol, I knew writing this would be like stirring up a hornet's nest. I already fixed the problem, I understood what went wrong. I don't need your condescension. Fucking "learn the basics", c'mon, too predictable.
  • 4
    @absurd people will tell you that you may cross the "you bein toxic" border here, but that's quite the rant. Take my upvote.

    Still, that's your fuckup lol
  • 1
  • 1
    Well, yeah, these two processes are asynchronous and not meant to be checked in one go. Even if you wrote it in Node.js, it still would require some library to hide the fact 🤔
  • 7
    @absurd condescension...

    Not really.

    Just stating the fact that if you directly interact with an output on a webserver without eg. an middleware to do the heavy lifting - you'll always end up with this situation.

    Be it PHP, C, Ruby or any other language executed directly - eg. via CGI.

    When you or the language do not utilise buffering, any output must be sent with some headers, as it will be sent immediately via HTTP.

    Without headers, you'd get a raw content stream.

    It's the things you should be aware of and that you should learn in great depth, as it can save you a lot of pain and grievance.
  • 4
    @absurd seriously mate, do you even basic? I won’t bother being nice, but don’t go bashing a language when you clearly haven’t grasped the basics of programming for the web.

    Haven’t got the slightest clue what you’re working on in the greater picture, but I’m pretty sure 7 or 8 times out of 10 you’d be better off with PHP (provided of course you have the skills to wield it) than JS.
  • 1
    Damn n00bs getting constantly fragged by most basic shit right at spawn...
  • 1
    A blank line before or after a function will trigger output without buffering being used.

    This is why on script only pages you can leave the trailing PHP close tags off to avoid this.

    Also don’t start your scripts with lines at the beginning.
Add Comment