array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'dom-tokenlist.contains.php', 1 => 'Dom\\TokenList::contains', 2 => 'Returns whether the list contains a given token', ), 'up' => array ( 0 => 'class.dom-tokenlist.php', 1 => 'Dom\\TokenList', ), 'prev' => array ( 0 => 'dom-tokenlist.add.php', 1 => 'Dom\\TokenList::add', ), 'next' => array ( 0 => 'dom-tokenlist.count.php', 1 => 'Dom\\TokenList::count', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/dom/dom/tokenlist/contains.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Dom\TokenList::contains

(PHP 8 >= 8.4.0)

Dom\TokenList::containsReturns whether the list contains a given token

Descrizione

public Dom\TokenList::contains(string $token): bool

Returns whether the list contains token.

Elenco dei parametri

token
The token.

Valori restituiti

Returns true if the list contains token, false otherwise.

Esempi

Example #1 Dom\TokenList::contains() example

Checks whether two classes are present on the paragraph.

<?php
$dom
= Dom\HTMLDocument::createFromString('<p class="font-bold important"></p>', LIBXML_NOERROR);
$p = $dom->body->firstChild;

$classList = $p->classList;
var_dump(
$classList->contains('important'),
$classList->contains('font-small'),
);
?>

Il precedente esempio visualizzerĂ :

bool(true)
bool(false)