yii\i18n\Formatter::asText PHP Метод

asText() публичный Метод

Formats the value as an HTML-encoded plain text.
public asText ( string $value ) : string
$value string the value to be formatted.
Результат string the formatted result.
    public function asText($value)
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
        return Html::encode($value);
    }

Usage Example

Пример #1
0
 public function testAsText()
 {
     $value = '123';
     $this->assertSame($value, $this->formatter->asText($value));
     $value = 123;
     $this->assertSame("{$value}", $this->formatter->asText($value));
     $value = '<>';
     $this->assertSame('&lt;&gt;', $this->formatter->asText($value));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asText(null));
 }