* @param string name the name of the var to search
* @param mixed value the variable to return
* @param int search constant defining where to look
+ * @param int typecast force variable to be cast to given type (please
+ * use SQ_TYPE_XXX constants or set to FALSE (default)
+ * to leave variable type unmolested)
* @return bool whether variable is found.
*/
function sqgetGlobalVar($name, &$value, $search = SQ_INORDER, $default = NULL, $typecast = false) {
}
if ($result && $typecast) {
switch ($typecast) {
- case 'int': $value = (int) $value; break;
- case 'bool': $value = (bool) $value; break;
+ case SQ_TYPE_INT: $value = (int) $value; break;
+ case SQ_TYPE_STRING: $value = (string) $value; break;
+ case SQ_TYPE_BOOL: $value = (bool) $value; break;
default: break;
}
} else if (!is_null($default)) {
define('SQM_COL_TO', 9);
define('SQM_COL_CC', 10);
define('SQM_COL_BCC', 11);
+
+/**
+ * Generic variable type constants
+ * @since 1.5.2
+ */
+define('SQ_TYPE_INT', 'int');
+define('SQ_TYPE_STRING', 'string');
+define('SQ_TYPE_BOOL', 'bool');
+define('SQ_TYPE_ARRAY', 'array');
+