
Request & Response
Request object, input handling, file uploads, response types, redirects, JSON responses, cookies, sessions
1Which method of the Request object allows retrieving the value of a form field?
Which method of the Request object allows retrieving the value of a form field?
답변
The input() method of the Request object allows retrieving data sent via GET, POST, or any other HTTP method. It accepts a field name as a parameter and returns its value, or null if the field does not exist. A default value can be passed as a second parameter to avoid null values.
2Which method allows checking if a specific field is present in the request?
Which method allows checking if a specific field is present in the request?
답변
The has() method checks if one or more fields are present in the request and contain a non-empty value. It returns a boolean. To simply check for field presence even if empty, use filled() which checks the field exists AND is not empty, or exists() to only check presence without validating the value.
3Which method allows retrieving all request fields as an array?
Which method allows retrieving all request fields as an array?
답변
The all() method returns all request data as an associative array. Unlike only() which filters specific fields, or except() which excludes certain fields, all() returns all submitted data. This method is useful for passing all data to validation or for global processing.
How to retrieve only specific fields from a request?
How to retrieve an uploaded file from an HTTP request?
+17 면접 질문