a::get PHP Method

get() static public method

Gets an element of an array by key
static public get ( array $array, mixed $key, mixed $default = null ) : mixed
$array array The source array
$key mixed The key to look for
$default mixed Optional default value, which should be returned if no element has been found
return mixed
    static function get($array, $key, $default = null)
    {
        return isset($array[$key]) ? $array[$key] : $default;
    }

Usage Example

示例#1
0
 function __construct($image, $options = array())
 {
     $this->root = c::get('thumb.cache.root', c::get('root') . '/thumbs');
     $this->url = c::get('thumb.cache.url', c::get('url') . '/thumbs');
     if (!$image) {
         return false;
     }
     $this->obj = $image;
     // set some values from the image
     $this->sourceWidth = $this->obj->width();
     $this->sourceHeight = $this->obj->height();
     $this->width = $this->sourceWidth;
     $this->height = $this->sourceHeight;
     $this->source = $this->obj->root();
     $this->mime = $this->obj->mime();
     // set the max width and height
     $this->maxWidth = @$options['width'];
     $this->maxHeight = @$options['height'];
     // set the quality
     $this->crop = @$options['crop'];
     // set the quality
     $this->quality = a::get($options, 'quality', c::get('thumb.quality', 100));
     // set the default upscale behavior
     $this->upscale = a::get($options, 'upscale', c::get('thumb.upscale', false));
     // set the alt text
     $this->alt = a::get($options, 'alt', $this->obj->name());
     // set the className text
     $this->className = @$options['class'];
     // set the new size
     $this->size();
     // create the thumbnail
     $this->create();
 }
All Usage Examples Of a::get