Loading...
PHP/MySQL | Фильтрация различных данных by MTV
plaintext

<?php
function filter_($string, $type) {
			if(is_string($string)) {
				switch($type) {
					case 1:
						$type = FILTER_SANITIZE_URL;
						break;
					case 2:
						$type = FILTER_SANITIZE_FULL_SPECIAL_CHARS;
						break;
					case 3:
						$type = FILTER_SANITIZE_NUMBER_INT;
						break;
					default:
						throw new LogicException('type is not selected.');
						break;
				}
				$string = stripslashes(trim($string));
				return filter_var($string, $type);
			}
		}
?>
Немного обновил
plaintext

<?php 

$id = filter_($_GET['id'],3);
$text = filter_($_POST['text'],2);
$url = filter_($_GET['path'],1);
$path = filter_($_SERVER['REQUEST_URI'],1);
?>

________
посл. ред. 07.10.2015 в 21:42; всего 1 раз(а); by MTV
MTV, такой 3 лет назад знали =)
262110938 (07.10.2015 в 21:41)
MTV, такой 3 лет назад знали =)
Да хоть и 10 :) Обычная процедурная функции фильтации данных :)
________
посл. ред. 07.10.2015 в 21:44; всего 1 раз(а); by MTV
Онлайн: 3
Время:
Gen. 0.0731
(c) Bym.Guru 2010-2026