首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

三元演算

2012-12-17 
三元运算//三元运算function getParam($param, $type, $default ){switch ($type){case POST :$resu

三元运算

//三元运算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');//不用默认值

热点排行