读书人

三元演算

发布时间: 2012-12-17 09:31:40 作者: rapoo

三元运算

//三元运算function getParam($param, $type, $default = ''){switch ($type){case 'POST' :$result = lib_replace_end_tag(trim($_POST[$param]));break;case 'GET' :$result = lib_replace_end_tag(trim($_GET[$param]));break;default :$result = lib_replace_end_tag(trim($_POST[$param] ? $_POST[$param] : $_GET[$param]));break;}$result = $result == '' ? $default : $result;return $result;}


POST:
getParam('yunli', 'post', '普通');
GET :
getParam('yunli', 'get', '普通');


$title = getParam('title', 'get', '标题');
$yunli = getParam('yunli', 'post', '普通');
$email = getParam('email', 'post');//不用默认值

读书人网 >编程

热点推荐