DOMDocument::loadHTML

(PHP 5, PHP 7, PHP 8)

DOMDocument::loadHTML Load HTML from a string

Beschreibung

public DOMDocument::loadHTML(string $source, int $options = 0): DOMDocument|bool

The function parses the HTML contained in the string source. Unlike loading XML, HTML does not have to be well-formed to load. This function may also be called statically to load and create a DOMDocument object. The static invocation may be used when no DOMDocument properties need to be set prior to loading.

Parameter-Liste

source

The HTML string.

options

Since Libxml 2.6.0, you may also use the options parameter to specify additional Libxml parameters.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben. If called statically, returns a DOMDocumentBei einem Fehler wird false zurückgegeben..

Fehler/Exceptions

If an empty string is passed as the source, a warning will be generated. This warning is not generated by libxml and cannot be handled using libxml's error handling functions.

Vor PHP 8.0.0 konnte diese Methode statisch aufgerufen werden, gab dabei aber einen Fehler der Stufe E_DEPRECATED aus. Seit PHP 8.0.0 löst der statische Aufruf dieser Methode eine Error-Exception aus.

Auch wenn fehlerhaftes HTML erfolgreich laden sollte, kann diese Funktion dennoch Fehler der Stufe E_WARNING generieren, wenn sie auf falsches Markup stößt. Die Fehlerbehandlungsfunktionen von libxml können genutzt werden, um diese Fehler zu behandeln.

Beispiele

Beispiel #1 Creating a Document

<?php
$doc 
= new DOMDocument();
$doc->loadHTML("<html><body>Test<br></body></html>");
echo 
$doc->saveHTML();
?>

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

AI Nude Tool—Make Deepnude & Deepfake for Free

Ein Thread voller Spam im Board IT-Security, genau mein Humor. :rofl:

Geschrieben von scatello am 05.04.2025 14:48:56
Forum: IT-Security
AI Nude Tool—Make Deepnude & Deepfake for Free

I've always been curious about numerology and your post answered so many questions! Destiny Matrix (https://destiny-matrix.cc/)​ has been my go- ...

Geschrieben von yxchen1994 am 05.04.2025 13:13:14
Forum: IT-Security
AI Nude Tool—Make Deepnude & Deepfake for Free

As a teacher, I use Ghiblify (https://ghiblify.run/) to transform classroom projects into magical scenes. My students are always excited to see th ...

Geschrieben von yxchen1994 am 05.04.2025 13:12:42
Forum: IT-Security
Helfen! Doppelte Bestelleinträge in meiner Verkaufstabelle

I am struggling to start learning about code. I have a background in economics Bendomenech68, ich betreibe Online-Handel seit 2010, und selbst da ...

Geschrieben von MannesHaar am 03.04.2025 16:21:46
Forum: SQL / Datenbanken