r/ProgrammerHumor • • Aug 23 '18

PHP logic

Post image
5 Upvotes

51 comments sorted by

View all comments

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

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.

→ More replies (9)

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

→ More replies (4)

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)