You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,6 +266,78 @@ if ($response->getStatusCode() === 200) {
266
266
echo 'Error: ' . $response->getReasonPhrase();
267
267
}
268
268
```
269
+
---
270
+
271
+
272
+
# Input
273
+
274
+
A simple, secure static helper class for reading and sanitizing `$_GET` and `$_POST` values in PHP. Part of the [MaplePHP HTTP](https://github.com/MaplePHP/Http) library.
275
+
276
+
### Checking if a key exists
277
+
278
+
```php
279
+
// Check in either $_GET or $_POST
280
+
Input::has('name');
281
+
282
+
// Check only in $_GET
283
+
Input::hasGet('page');
284
+
285
+
// Check only in $_POST
286
+
Input::hasPost('email');
287
+
```
288
+
289
+
---
290
+
291
+
### Reading encoded (safe) values
292
+
293
+
Values are automatically HTML-encoded to prevent XSS. Returns `null` if the key does not exist.
294
+
295
+
```php
296
+
// From $_GET
297
+
$page = Input::get('page');
298
+
299
+
// From $_POST
300
+
$email = Input::post('email');
301
+
302
+
// From $_GET or $_POST (GET takes priority)
303
+
$id = Input::request('id');
304
+
305
+
// With a fallback default
306
+
$page = Input::get('page', '1');
307
+
```
308
+
309
+
---
310
+
311
+
### Reading raw (unencoded) values
312
+
313
+
Use raw methods when you need the original unmodified value, or when working with array inputs.
314
+
315
+
```php
316
+
// Scalar raw value
317
+
$name = Input::getRaw('name');
318
+
319
+
// Array input e.g. $_POST['tags'][]
320
+
$tags = Input::postRaw('tags');
321
+
322
+
// With a fallback default
323
+
$filters = Input::getRaw('filters', []);
324
+
```
325
+
326
+
> **Note:** Raw values are not sanitized. Make sure to validate or sanitize them before use.
327
+
328
+
---
329
+
330
+
### Reading all input
331
+
332
+
```php
333
+
// All raw merged input from $_GET and $_POST (POST takes priority)
334
+
$data = Input::all();
335
+
336
+
// All encoded merged input, including nested arrays
0 commit comments