yii\gii\CodeFile::preview PHP Method

preview() public method

Returns preview or false if it cannot be rendered
public preview ( ) : boolean | string
return boolean | string
    public function preview()
    {
        if (($pos = strrpos($this->path, '.')) !== false) {
            $type = substr($this->path, $pos + 1);
        } else {
            $type = 'unknown';
        }
        if ($type === 'php') {
            return highlight_string($this->content, true);
        } elseif (!in_array($type, ['jpg', 'gif', 'png', 'exe'])) {
            return nl2br(Html::encode($this->content));
        } else {
            return false;
        }
    }