本文整理汇总了PHP中app\File::mask方法的典型用法代码示例。如果您正苦于以下问题:PHP File::mask方法的具体用法?PHP File::mask怎么用?PHP File::mask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\File
的用法示例。
在下文中一共展示了File::mask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Gets a value from the request data
*
* A value that exactly equals `''` and is not cast to a specific type will
* become `NULL`.
*
* Valid `$cast_to` types include:
* - `'string'`
* - `'binary'`
* - `'int'`
* - `'integer'`
* - `'bool'`
* - `'boolean'`
* - `'array'`
* - `'date'`
* - `'time'`
* - `'timestamp'`
*
* It is possible to append a `?` to a data type to return `NULL`
* whenever the `$key` was not specified in the request, or if the value
* was a blank string.
*
* The `array` and unspecified `$cast_to` types allow for multi-dimensional
* arrays of string data. It is possible to cast an input value as a
* single-dimensional array of a specific type by appending `[]` to the
* `$cast_to`.
*
* All `string`, `array` or unspecified `$cast_to` will result in the value(s)
* being interpreted as UTF-8 string and appropriately cleaned of invalid
* byte sequences. Also, all low-byte, non-printable characters will be
* stripped from the value. This includes all bytes less than the value of
* 32 (Space) other than Tab (`\t`), Newline (`\n`) and Cariage Return
* (`\r`).
*
* To preserve low-byte, non-printable characters, or get the raw value
* without cleaning invalid UTF-8 byte sequences, plase use the value of
* `binary` for the `$cast_to` parameter.
*
* Any integers that are beyond the range of 32bit storage will be returned
* as a string. The returned value can be forced to always be a real
* integer, which may cause truncation of the value, by passing `integer!`
* as the `$cast_to`.
*
* @param string $key The key to get - array elements can be accessed via `[sub-key]`
* @param string $cast_to Cast the value to this data type
* @param mixed $default_value If the parameter is not set use this value instead.
* @param boolean $default_on_blank Return NULL if request value and default are empty
* @return mixed The value
*/
public function get($key, $cast_to = NULL, $default = NULL, $default_on_blank = FALSE)
{
$value = $default;
if ($cast_to == 'file') {
try {
$name = Flourish\Core::dereference($key, $this->files['name']);
$file = Flourish\Core::dereference($key, $this->files['tmp_name']);
$error = Flourish\Core::dereference($key, $this->files['error']);
if (!$error) {
$value = new App\File($file);
$value->mask($name);
} else {
// UPLOAD_ERR_INI_SIZE: 1
// UPLOAD_ERR_FORM_SIZE: 2
// UPLOAD_ERR_NO_TMP_DIR: 6
// UPLOAD_ERR_CANT_WRITE: 7
// UPLOAD_ERR_EXTENSION: 8
// UPLOAD_ERR_PARTIAL: 3
}
} catch (Flourish\ProgrammerException $e) {
if ($default) {
$value = new App\File($default);
}
}
} else {
try {
$value = Flourish\Core::dereference($key, $this->data);
if ($value === '' && $default_on_blank && $default !== NULL) {
$value = $default;
}
} catch (Flourish\ProgrammerException $e) {
$value = $default;
}
//
// This allows for data_type? casts to allow NULL through
//
if ($cast_to !== NULL && substr($cast_to, -1) == '?') {
if ($value === NULL || $value === '') {
return NULL;
}
$cast_to = substr($cast_to, 0, -1);
}
$value = self::cast($value, $cast_to);
}
return $value;
}