-
Notifications
You must be signed in to change notification settings - Fork 34
classes_base_args.class
Generic Argument wrapper class Provides functionality to savely get values from the $_GET, $_POST,... superglobals. Supports:
- GET
- POST
- COOKIE
- SERVER
- ENV
- SESSION
Use the shortcut methods if you want to query a specific (of the) variables (above). Args::get(...), Args::post(...),... You may use the Args::request method to query a mix of the superglobals defined by the Args::setOrder() method (default is GPC -> Cookie overrides Post overrides Get).
See method commets for details.
Clears all internal buffers. In some cases it may be usefule to let Args parse again instead of relying on previously calculated values.
Definition: public static function clearBuffer()
Returns: void
SHORTCUT To access COOKIE values.
SHORTCUT To access ENV values.
SHORTCUT To access GET values.
SHORTCUT To access POST values.
SHORTCUT To access REQUEST values. Uses the default (or set via setOrder) superglobal query order.
Performs value sanitation. Sanitizes a value with a given filter. Valid values for $filter are all PHP defined FILTER_SANITIZE_* constants or a string value. If $filter is one of those constants, $filter_options apply as in PHP documentation. See http://www.php.net/manual/en/filter.filters.sanitize.php for details on that. If $filter is a string see code below for details. Mentionable here:
- 'array': Will treat value as an array. You may provide filter_options to be a string (like 'int') defining a type for all array elements or to be an array that should contain the same keys (count and name) as the value and each filter_option[key] value defines another type. Sample: $filter='array', $filter_options=array('int','bool','string')
- 'object': Will treat the value as object and simply return it if it is one. May also be a string defining the storage_id of an object in object store. In that case restore_object($value) will be returned.
Another note: sanitize will fill the log with messages severity WARN if something unexpected happen. This is especially the case when default values are returned for invalid inputs. So have an eye on the logs!
Definition: public static function sanitize($value, $filter, $filter_options=null)
Returns: mixed The sanitized value
Parameters:
-
mixed $valueThe value to be sanitized -
int|string $filterType of filter -
mixed $filter_optionsOptional options for the filter
Returns a names variable Queries the Superglobals for a variable named $name and optionally filters it for a specific type. Superglobals to be included in the query and their order may be given optionally.
For details on the possible values for $filter see Args::sanitize below.
Definition: public static function sanitized($name=false, $default=null, $order=null, $filter=null, $filter_options=null)
Returns: mixed Sanitized value or a list of requested array's keys
Parameters:
-
string $nameName of the variable, if false a list of keys in the requested array is returned -
mixed $defaultDefault value, null if none -
string $orderSpecific Superglobals order. NULL if default shall be used. See setOrder for details -
int|string $filterSpecifies a filter to apply on the value. See description above -
mixed $filter_optionsOptional options for the $filter argument
SHORTCUT To access SERVER values.
SHORTCUT To access SESSION values.
Sets a CultureInfo object. This is optional but will allow you to parse inputs correctly in a given Cultures format. So if the user enters a number like this 1,042.23 (one thousant fourty two point twenty three) this is US formatting and can pe parsed successfully to 1042.23 if you provide an en-US culture. If not it will result in an invalid float value.
Definition: public static function setCultureInfo($cultureInfo)
Returns: void
Parameters:
-
CultureInfo $cultureInfoCi to set
Sets ignore case flag. If true, Args class will ignore the case of the argument names. If false will respect case.
Definition: public static function setIgnoreCase($ignore)
Returns: void
Parameters:
-
bool $ignoretrue|false
Sets the default superglobal query range. Supported values and their meanings: G - GET P - POST C - COOKIE S - SERVER E - ENV O - SESSION (use O to have the S for PHP compatibility as it means SERVER there)
Note: GPC is default. This will use Cookie before Post before Get, so order is reversed!
Definition: public static function setOrder($order)
Returns: void
Parameters:
-
string $orderOrder string (sample: GPCSEO)
Strips given tags from request data.
Definition: public static function strip_tags()
Returns: void