battles/classes/input.php
2019-06-21 00:48:46 +03:00

31 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
class input
{
public static function get($name) {
$var = trim(filter_input(INPUT_GET,$name));
if (isset($var) AND !empty($var))
return $var;
else return null;
}
public static function post($name) {
$var = trim(filter_input(INPUT_POST,$name));
if (isset($var) AND !empty($var))
return $var;
else return null;
}
public static function check($name) {
# Срезаем с значения переменной табы, пробелы, другие невидимые символы по краям.
# Проверяем, что у переменной точно есть значение.
if (!empty(trim(filter_input(INPUT_GET,$name)))) return trim(filter_input(INPUT_GET,$name));
if (!empty(trim(filter_input(INPUT_POST,$name)))) return trim(filter_input(INPUT_POST,$name));
return null;
}
}