原生模仿CI框架(php)的 $this->input
<?php
public function input($param, $method = 'all', $default = '')
{
$method = strtolower($method);
$method = in_array($method, array('get', 'post', 'all')) ? $method : 'all';
switch ($method) {
case 'get' :
$params = $_GET;
break;
case 'post' :
$params = $_POST;
break;
default :
$params = array_merge($_GET, $_POST);
break;
}
$ret = isset($params[$param]) ? $params[$param] : $default;
// stripslashes 删除反斜杠
return stripslashes($ret);
}
使用:
$id = intval($this->input('id'));