Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Strip HTML and PHP tags from a string
strip_tags(string $string, array|string|null $allowed_tags = null): string
public function alert($string)
{
$length = Str::length(strip_tags($string)) + 12;
$this->comment(str_repeat('*', $length));
$this->comment('* '.$string.' *');
{
$length = Str::length(strip_tags($string)) + 12;
$this->comment(str_repeat('*', $length));
$this->comment('* '.$string.' *');
return [(string) Str::of($section)->snake() => collect($data)->mapWithKeys(fn ($item, $key) => [(string) Str::of($item[0])->lower()->snake() => value($item[1])])];
});
$this->output->writeln(strip_tags(json_encode($output)));
}
});
$this->output->writeln(strip_tags(json_encode($output)));
}
protected function parseChoice($choice)
{
[$type, $value] = explode(': ', strip_tags($choice));
if ($type === 'Provider') {
$this->provider = $value;
{
[$type, $value] = explode(': ', strip_tags($choice));
if ($type === 'Provider') {
$this->provider = $value;
public function stripTags($allowedTags = null)
{
return new static(strip_tags($this->value, $allowedTags));
}
{
return new static(strip_tags($this->value, $allowedTags));
}
{
$value = $escape ? e($value) : $value;
PHPUnit::assertStringContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$value = $escape ? e($value) : $value;
PHPUnit::assertStringContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
{
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));
return $this;
}
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));
return $this;
}
{
$value = $escape ? e($value) : $value;
PHPUnit::assertStringNotContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$value = $escape ? e($value) : $value;
PHPUnit::assertStringNotContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$values = $escape ? array_map('e', ($value)) : $value;
tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
PHPUnit::assertStringContainsString((string) $value, $content);
}
tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
PHPUnit::assertStringContainsString((string) $value, $content);
}
{
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->getContent())));
return $this;
}
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->getContent())));
return $this;
}
$values = $escape ? array_map('e', ($value)) : $value;
tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
PHPUnit::assertStringNotContainsString((string) $value, $content);
}
tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
PHPUnit::assertStringNotContainsString((string) $value, $content);
}
{
$value = $escape ? e($value) : $value;
PHPUnit::assertStringContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$value = $escape ? e($value) : $value;
PHPUnit::assertStringContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
{
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));
return $this;
}
$values = $escape ? array_map('e', ($values)) : $values;
PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));
return $this;
}
{
$value = $escape ? e($value) : $value;
PHPUnit::assertStringNotContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$value = $escape ? e($value) : $value;
PHPUnit::assertStringNotContainsString((string) $value, strip_tags($this->rendered));
return $this;
}
$this->assertSame('...ayl...', Str::excerpt('taylor', 'Y', ['radius' => 1]));
$this->assertSame('<div> The article description </div>', Str::excerpt('<div> The article description </div>', 'article'));
$this->assertSame('...The article desc...', Str::excerpt('<div> The article description </div>', 'article', ['radius' => 5]));
$this->assertSame('The article description', Str::excerpt(strip_tags('<div> The article description </div>'), 'article'));
$this->assertSame('', Str::excerpt(null));
$this->assertSame('', Str::excerpt(''));
$this->assertSame('', Str::excerpt(null, ''));
$this->assertSame('<div> The article description </div>', Str::excerpt('<div> The article description </div>', 'article'));
$this->assertSame('...The article desc...', Str::excerpt('<div> The article description </div>', 'article', ['radius' => 5]));
$this->assertSame('The article description', Str::excerpt(strip_tags('<div> The article description </div>'), 'article'));
$this->assertSame('', Str::excerpt(null));
$this->assertSame('', Str::excerpt(''));
$this->assertSame('', Str::excerpt(null, ''));
$output = ob_get_clean();
assert(is_string($output));
return strip_tags(html_entity_decode($output));
} finally {
ini_set('html_errors', $html);
}
assert(is_string($output));
return strip_tags(html_entity_decode($output));
} finally {
ini_set('html_errors', $html);
}