Skip to content

Commit d0c1d5b

Browse files
committed
docs: add explanations to getGet()
getVar() is not recommended.
1 parent d46f10a commit d0c1d5b

6 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎user_guide_src/source/incoming/incomingrequest.rst‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,34 @@ The methods provided by the parent classes that are available are:
405405
:returns: ``$_GET`` if no parameters supplied, otherwise the GET value if found, or null if not
406406
:rtype: array|bool|float|int|object|string|null
407407

408-
This method is identical to ``getVar()``, only it fetches GET data.
408+
The first parameter will contain the name of the GET item you are looking for:
409+
410+
.. literalinclude:: incomingrequest/041.php
411+
412+
The method returns null if the item you are attempting to retrieve
413+
does not exist.
414+
415+
The second optional parameter lets you run the data through the PHP's
416+
filters. Pass in the desired filter type as the second parameter:
417+
418+
.. literalinclude:: incomingrequest/042.php
419+
420+
To return an array of all GET items call without any parameters.
421+
422+
To return all REQUEST items and pass them through the filter, set the
423+
first parameter to null while setting the second parameter to the filter
424+
you want to use:
425+
426+
.. literalinclude:: incomingrequest/043.php
427+
428+
To return an array of multiple GET parameters, pass all the required keys as an array:
429+
430+
.. literalinclude:: incomingrequest/044.php
431+
432+
Same rule applied here, to retrieve the parameters with filtering, set the second parameter to
433+
the filter type to apply:
434+
435+
.. literalinclude:: incomingrequest/045.php
409436

410437
.. php:method:: getPost([$index = null[, $filter = null[, $flags = null]]])
411438
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$request->getGet('some_data');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$request->getGet('some_data', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$request->getGet(null, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
4+
// returns all GET items with string sanitation
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$request->getGet(['field1', 'field2']);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$request->getGet(['field1', 'field2'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);

0 commit comments

Comments
 (0)