PHP filter_input

filter_input - Gets a specific external variable by name and optionally filters it

 filter_input ( int $type , string $variable_name [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) : mixed

Parameters
type - One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.
variable_name - Name of a variable to get.
filter - The ID of the filter to apply. The Types of filters manual page lists the available filters.

If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default.

options - Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array.


Types of filters
Validate filters
Sanitize filters
Other filters
Filter flags

$search = filter_input(INPUT_GET, 'search');

or
// FILTER_SANITIZE_STRING :  Strip tags, optionally strip or encode special characters.
$search = filter_input(INPUT_GET, 'search' , FILTER_SANITIZE_STRING); 
or
// FILTER_SANITIZE_SPECIAL_CHARS :  HTML-escape '"<>& and characters with ASCII value less than 32, optionally strip or encode other special characters.
$search = filter_input(INPUT_GET, 'search' , FILTER_SANITIZE_SPECIAL_CHARS); 

Links:
PHP filter_has_var