3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = ' <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>We <em>love</em> HTML!</title> </head> <body> </body> </html> '; function run_tests( $document ) { $title = $document->getElementsByTagName( 'title' )->item( 0 ); if ( $title->childNodes->length !== 1 ) { echo "FAIL: Title tag does not have the the expected single text child. Has {$title->childNodes->length} children.\n"; } else { echo "PASS: Title tag only has a single child.\n"; } if ( $title->getElementsByTagName( 'em' )->length !== 0 ) { echo "FAIL: Title tag unexpectedly has a parsed EM child.\n"; } else { echo "PASS: Title tag has no child EM element.\n"; } if ( false !== strpos( $title->textContent, '<em>' ) ) { echo "PASS: HTML tag <em> was not parsed. Text content: {$title->textContent}\n"; } else { echo "FAIL: HTML tag <em> was parsed. Text content: {$title->textContent}\n"; } } echo "# DOMDocument:\n"; $old_document = new DOMDocument(); $old_document->loadHTML( $html ); run_tests( $old_document ); echo "\n"; echo "# Dom\HTMLDocument:\n"; if ( class_exists( Dom\HTMLDocument::class ) ) { $new_document = Dom\HTMLDocument::createFromString( $html ); run_tests( $new_document ); } else { echo "(Not available)\n"; }
Output for git.master_jit, git.master
# DOMDocument: FAIL: Title tag does not have the the expected single text child. Has 3 children. FAIL: Title tag unexpectedly has a parsed EM child. FAIL: HTML tag <em> was parsed. Text content: We love HTML! # Dom\HTMLDocument: PASS: Title tag only has a single child. PASS: Title tag has no child EM element. PASS: HTML tag <em> was not parsed. Text content: We <em>love</em> HTML!

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.67 ms | 2882 KiB | 4 Q