是长网址字符串中的空参数可接受的做法[复制]

This question already has an answer here:

This post indicates that an empty parameter in a URL string isn't such a bad thing. But it only asks about one parameter. It may seem a silly extension of the question, but if I have a long list of parameters, is it still considered acceptable practice?

www.web.com?id=123&last_purchase_id=&last_purchase_date=&is_buyer=false

</div>

Are empty parameters in a long url string acceptable practice?

Yes and No.

Yes in the fact that even an empty value represents a value. That is the absence of a value. Use cases would be reset, default, or opt-out a parameter.

No in the fact that if empty parameters are required for your code to properly execute. Instead you should default those values in code.

There is a difference to the server between empty parameters and the non-existence of parameters.

isset($_GET['last_purchase_id'])

would be true even for an empty last_purchase_id. Therefore, whether you send the server empty parameters is up to your server's current implementation.