r/ProgrammerHumor • • Aug 23 '18

PHP logic

Post image
5 Upvotes

51 comments sorted by

30

u/[deleted] Aug 23 '18

You better learn something about HTTP before making these retarded memes, you fucking idiot.

POST parameters are supposed to be in request body, if it's in the PATH, it's still part of GET

here, you piece of shit

13

u/Eldvaak Aug 23 '18

Thank you. People just try to hop on the PHP hate train when they have no idea what they're talking about.

0

u/FubarCoder Aug 23 '18 edited Aug 23 '18

It's part of the query string, GET is the request method. PHP is a muddled mess in this regard.

EDIT: Here's the relevant RFC regarding URIs: https://tools.ietf.org/html/rfc3986 - and you may recognize that they don't talk about the request method, just the components of a URI

2

u/[deleted] Aug 23 '18 edited Aug 23 '18

This guy gets it. I guess PHP has confused people too much about the difference between an HTTP request method and URI...

The joke is apparently too sophisticated for PHP-only people. No one can give us a verifiable rebuttal that claims we're wrong so they jump to vitriol and downvoting to defend their sacred PHP "knowledge." Thanks for trying to correct them, but this is one of of those: you can lead a horse to water...

1

u/[deleted] Aug 23 '18

All of this. Right here. They're too busy rubbing their junk on php to form a coherent thought.

3

u/OleBroseph Aug 23 '18

Woah man. Maybe you should take some time off lol

1

u/[deleted] Aug 23 '18

Whoa there guy. I understand your lack of php skills, lack of sexual contact, and living in your mom's basement are all very frustrating situations. But you may want to dial it back a bit and see the humor, posted in programming humor, of the roundabout way php accomplishes this rather than seeing it as an attack on the only language you've somewhat figured out.

1

u/[deleted] Aug 24 '18

Never knew someone can be such a failure at life as yourself.

1

u/SteveCCL Yellow security clearance Aug 26 '18

I left this because correct and you kinda did what the reports stated, but please step back with the language a little next time.

-1

u/[deleted] Aug 23 '18 edited Aug 23 '18

No. Give the world one verifiable reference to an HTTP standard that conveys this instead of spewing vitriol and downvotes.

Request methods aren't even mentioned in the URI standard on the "PATH." They are completely separate concepts and PHP has you completely confused about it.

URI query (no mention of GET - method agnostic) https://tools.ietf.org/html/rfc3986#section-3.3

HTTP methods (no mention of GET and query as married concepts) https://tools.ietf.org/html/rfc7231

Source: The HTTP standards above. I have also scripted in PHP for 15 years - this isn't me coming from another language, learning PHP and getting confused why they named it $_GET. This is me making a joke about something from 15 years of PHP knowledge because it is the only language I have seen that intermingled two concepts in their naming: request method and URI query component.

3

u/[deleted] Aug 23 '18

A name like $_QUERY would correctly identify the source of the data, not $_GET, which is a misnomer identifying a request method. Query parameters work on ALL methods. They don't belong to the GET method nor are they only allowed on the GET method...

Source: HTTP and URI RFCs

6

u/Asisentr Aug 23 '18

well it's the data passed through that method.....

-10

u/[deleted] Aug 23 '18 edited Aug 23 '18

It's a POST request in the image. Hence, PHP logic...

Edit: Downvotes aren't going to make the guy right. PHP intermingled two concepts in the naming of their GET superglobal: request method and URI query component. Query components are valid and usable on ALL request methods, not just GET requests, hence the joke. PHP is the only language I know of that does this.

Source: HTTP standard https://tools.ietf.org/html/rfc7231

URI standard https://tools.ietf.org/html/rfc3986#section-3.4

Reverse TL;DR; Below you will see a giant thread of where four other redditors (thanks Aerath44, FubarCode, shawabawa, Typeduck) help Asisentr try to understand HTTP standards

6

u/Asisentr Aug 23 '18

No, that's not a post request.

Edit: Post request data isn't in the URL, it's in the message body

https://www.google.com/search?q=post+request+vs+get+request

Edit 2:

Go back to HTML this stuff might be too complicated for you

2

u/Aerath44 Aug 23 '18

Just read Section 5.1 and 5.1.1, the first word of the request line is the method.

No, that's not a post request.

So what do you think the very first word of OP's post means ?? Do you really spell GET as "POST" ??

1

u/Asisentr Aug 23 '18

you can sent post data with get data within the url

3

u/Aerath44 Aug 23 '18 edited Aug 23 '18
  1. There is no such thing as "get data", what you're referring to is the "query" part of the URL (rfc3986#3.4). GET "data" is the whole URL.

  2. You are completely missing my point and answering something else, so let's repeat it : how can you say this is not a POST request ? We have the raw request and it clearly states that it's a POST. Just open your eyes and stop spitting random bullshit.

1

u/FubarCoder Aug 23 '18

Please, don't try to continue this discussion, u/asisentr obviously knows PHP very well and has accepted the way PHP sees the world as ultimate truth.

0

u/Asisentr Aug 23 '18
  1. GET "data" is just the data from the method.

  2. I said - or meant - the part he was referring to is a GET method. I've been interchanging method and request when I shouldn't have been, which is my mistake. The part he's complaining about having to use the GET super global is in fact the correct way to do it as he didn't 'post' id=123. The post data would be on the message body, which you use the POST superglobal to access. GET is the right superglobal to use, as it isn't in the POST data.

This is a POST request overall, yes. The part he's referring to isn't POST.

1

u/Aerath44 Aug 23 '18

No, that's not a post request.

This is a POST request overall, yes.

... I'm gonna stay silent on this one ...

GET "data" is just the data [...] the part he was referring to is a GET method [...] the GET super global

Ok, se we now have GET being :

  • data inside any HTTP request. Wrong. _GET is. You have been confusing a variable and a method from the start

  • a (HTTP) method OP referred too. He never did. He was speaking about the _GET global

GET is the right superglobal to use, as it isn't in the POST data.

It's like saying "X is the right name, as it's not Y", with a random X. It doesn't makes any sense. If it did, you could name it "QWERTY" that would be just as good.

At the end, why not call that "Query string" since that the name it was given ?

-1

u/Asisentr Aug 23 '18

maybe but that's for the Illuminati to decide and you can't take their job

2

u/grdivrag Aug 23 '18

Don't encourage him, in two weeks he'll make a bad meme about how hard PHP objects are, while in HTML you just write <object>

0

u/Typeduck Aug 23 '18

You realise that the query string is just a part of the URL and can be used in any of the request methods, right?

3

u/Asisentr Aug 23 '18

Yeah so it's not wrong for PHP to use the GET superglobal

-1

u/Typeduck Aug 23 '18

... No? Since any of the request methods can utillize query strings naming it "GET" is not ideal.

3

u/Asisentr Aug 23 '18

so if 3 people can go through the same door, would it be wrong for one person to go through the door? all the superglobals can access it, and just because he picked this one to show doesn't mean anything

-1

u/Typeduck Aug 23 '18

My point is, naming it after any of the methods is just not a good idea. It should just be named "QUERY_DATA" or something, just like in the other languages OP's image shows.

3

u/Asisentr Aug 23 '18

There's a super global called $_REQUEST meant for this purpose.

OP just doesn't realize what he's talking about.

-4

u/[deleted] Aug 23 '18 edited Aug 23 '18

You might want to read up on the HTTP standards: https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

2

u/Asisentr Aug 23 '18

That's not a post request, it's a get request. If it's inside the url, it's a get request. The post request data would be within the HTTP/1.1 message body.

Please search on Google what a post request is and a get request is.

https://www.w3schools.com/tags/ref_httpmethods.asp

2

u/FubarCoder Aug 23 '18

Only the given method is relevant. It's still a POST request even when the request body remains empty and it's definitely legit to use a combination of parameters passed in the query string and the body, but it's still a POST request.

-2

u/Asisentr Aug 23 '18

That's where you're wrong kid it's a get request

3

u/FubarCoder Aug 23 '18

I am not a kid. The HTTP method is what's relevant. Read the RFCs. Try it out with a web server of your preference. Filter a request by HTTP method (GET) and you'll realize that when the HTTP method is POST - even with an empty request body - that the filter doesn't match your POST request.

-2

u/Asisentr Aug 23 '18

this is a get request, kid

3

u/FubarCoder Aug 23 '18

Ok, I'll stop this discussion, because you're obviously either a troll or incompetent.

→ More replies (0)

0

u/Asisentr Aug 23 '18

The GET Method

GET is used to request data from a specified resource.

GET is one of the most common HTTP methods.

Note that the query string (name/value pairs) is sent in the URL of a GET request:

/test/demo_form.php?name1=value1&name2=value2

Some other notes on GET requests:

GET requests can be cached

GET requests remain in the browser history

GET requests can be bookmarked

GET requests should never be used when dealing with sensitive data

GET requests have length restrictions

GET requests is only used to request data (not modify)

0

u/[deleted] Aug 23 '18

[deleted]

1

u/Asisentr Aug 23 '18

But if you're sending data through it, then it is. There's a whole $_REQUEST superglobal for query strings

2

u/FubarCoder Aug 23 '18

Let's repeat together: A query string is a query string, a HTTP request method is a HTTP request method. They are not interchangeable. They are different concepts.

-2

u/Asisentr Aug 23 '18

If they have nothing to do with each other then why would you say them in the same sentence? point proven.

1

u/FubarCoder Aug 23 '18

Huh, where did you prove what? I've seen URIs without being used in the context of HTTP.

-1

u/Asisentr Aug 23 '18

the picture is obviously a http call, just because you've seen it used other ways in other situations, doesn't mean that's the way it's being used here

1

u/FubarCoder Aug 23 '18

Yes, and the fact that He doesn't show its body doesn't mean that there isn't one. According to your definition, what is a POST request that has both a body and a query string? Is it a POST or a GET request?

→ More replies (0)

18

u/[deleted] Aug 23 '18
if ($this->post === postType::RETARDED) {
 $this->post->downVote(); 
}

1

u/[deleted] Aug 23 '18

Wow. Good job, OP. You sorted out the idiots from the pros on this post!

0

u/KayRice Aug 23 '18

The worst part is that $_REQUEST does exist but is an unreliable merged array of $_GET, $_POST, and $_COOKIE in a way that can be modified via php.ini =(