@@ -186,13 +186,15 @@ public function hasGetParam($key) {
186
186
187
187
/**
188
188
* Returns the GET parameter value from the request.
189
- * @param string $key - the parameter name
190
- * @param mixed $default - the default value to return when parameter does not exist (optional, default is NULL).
189
+ * @param string $key - the parameter name
190
+ * @param mixed $default - the default value to return when parameter does not exist (optional, default is NULL).
191
+ * @param object $filter - a filter to sanitize the value.
191
192
* @return mixed the parameter value or its default.
192
193
*/
193
- public function getGetParam ($ key , $ default = NULL ) {
194
+ public function getGetParam ($ key , $ default = NULL , $ filter = NULL ) {
194
195
$ params = $ this ->getParams ;
195
- return isset ($ params [$ key ]) ? $ params [$ key ] : $ default ;
196
+ if ($ filter == NULL ) $ filter = StringFilters::$ NO_HTML ;
197
+ return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
196
198
}
197
199
198
200
/**
@@ -214,13 +216,15 @@ public function hasPostParam($key) {
214
216
215
217
/**
216
218
* Returns the POST parameter value from the request.
217
- * @param string $key - the parameter name
218
- * @param mixed $default - the default value to return when parameter does not exist (optional, default is NULL).
219
+ * @param string $key - the parameter name
220
+ * @param mixed $default - the default value to return when parameter does not exist (optional, default is NULL).
221
+ * @param object $filter - a filter to sanitize the value.
219
222
* @return mixed the parameter value or its default.
220
223
*/
221
- public function getPostParam ($ key , $ default = NULL ) {
224
+ public function getPostParam ($ key , $ default = NULL , $ filter = NULL ) {
222
225
$ params = $ this ->getPostParams ();
223
- return isset ($ params [$ key ]) ? $ params [$ key ] : $ default ;
226
+ if ($ filter == NULL ) $ filter = StringFilters::$ NO_HTML ;
227
+ return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
224
228
}
225
229
226
230
/**
0 commit comments