Function admFuncVariableIsValid
The function is designed to check the content of @b $_GET and @b $_POST elements and should be used at the beginning of a script. If the value of the defined datatype is not valid then an error will be shown. If no value was set then the parameter will be initialized. The function can be used with every array and their elements. You can set several flags (like required value, datatype …) that should be checked.
License: GNU General Public License v2.0 only **********************************************************************************************
B:
date or @b file that is expected and which will be checked. Datatype @b date expects a date that has the Admidio default format from the preferences or the english date format @b Y-m-d
Code:
// numeric value that would get a default value 0 if not set $getDateId = admFuncVariableIsValid($_GET, 'dat_id', 'numeric', array('defaultValue' => 0));
// string that will be initialized with text of id DAT_DATES $getHeadline = admFuncVariableIsValid($_GET, 'headline', 'string', array('defaultValue' => $g_l10n->get('DAT_DATES')));
// string initialized with actual and the only allowed values are actual and old $getMode = admFuncVariableIsValid($_GET, 'mode', 'string', array('defaultValue' => 'actual', 'validValues' => array('actual', 'old')));
Endcode
Par: Examples
Located at
Parameters summary
array |
$array |
The array with the element that should be checked |
string |
$variableName |
Name of the array element that should be checked |
string |
$datatype |
The datatype like @b string, @b numeric, @b int, @b float, @b bool, @b boolean, @b html, |
array |
$options = array() |
<p>(optional) An array with the following possible entries: - @b defaultValue : A value that will be set if the variable has no value - @b requireValue : If set to @b true than a value is required otherwise the function returns an error - @b validValues : An array with all values that the variable could have. If another value is found than the function returns an error - @b directOutput : If set to @b true the function returns only the error string, if set to false a html message with the error will be returned</p> |
Return value summary
mixed|null
|
Returns the value of the element or the error message if a test failed |