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

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

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

Usage Example

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