79105312

Date: 2024-10-19 15:42:04
Score: 2
Natty:
Report link

Here's another suggestion. Maybe helpful if you are looking in a specific POST value such as 'foo'. Above, HelpNeeder introduced the filter_input() function, great for filtering user input.

//php 8.1
// example.com?foo=bar
$query = 'bar';

if (filter_has_var($_SESSION['REQUEST_METHOD']))
{
    $test = filter_input(INPUT_POST, 'foo', FILTER_SANITIZE_SPECIAL_CHARS);
    if (null != $test && $query === $test)
    {
            //...
    }
}

https://www.php.net/manual/en/function.filter-input.php

https://www.php.net/manual/en/function.filter-has-var.php

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: john