🐘 PHP
Beginner
What is the difference between GET and POST methods in PHP?
Answer
The GET method sends data appended to the URL as query parameters (?name=Alice&age=25), accessible via $_GET. GET requests are cached, stored in browser history, can be bookmarked, and have URL length limits (around 2048 characters). They should only be used for retrieving data (idempotent operations). The POST method sends data in the HTTP request body, accessible via $_POST. POST data is not visible in the URL, not cached, not stored in browser history, and has no practical size limit. Use POST for submitting forms with sensitive data (passwords), uploading files, or any operation that modifies server state (creating, updating, deleting records).