Statement on glibc/iconv Vulnerability

DOMElement::insertAdjacentText

(PHP 8 >= 8.3.0)

DOMElement::insertAdjacentText隣接するテキストを挿入する

説明

public DOMElement::insertAdjacentText(string $where, string $data): void

where で指定された相対的な位置に、 テキストを挿入します。

パラメータ

where

  • beforebegin - 目的の要素の直前に挿入します
  • afterbegin - 目的の要素の最初の子要素として挿入します
  • beforeend - 目的の要素の最後の子要素として挿入します
  • afterend - 目的の要素の直後に挿入します

data

挿入する文字列

戻り値

値を返しません。

例1 DOMElement::insertAdjacentText() の例

<?php

$dom
= new DOMDocument();
$dom->loadXML('<?xml version="1.0"?><container><p>H</p></container>');

$container = $dom->documentElement;
$p = $container->firstElementChild;

$p->insertAdjacentText("afterbegin", "P");
$p->insertAdjacentText("beforeend", "P");

echo
$dom->saveXML();
?>

上の例の出力は以下となります。

<?xml version="1.0"?>
<container><p>PHP</p></container>

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top