3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_script_tags($html){ $dom = new DOMDocument(); $dom->loadHTML($html); $script = $dom->getElementsByTagName('script'); $remove = []; foreach($script as $item){ $remove[] = $item; } foreach ($remove as $item){ $item->parentNode->removeChild($item); } $html = $dom->saveHTML(); $html = preg_replace('/<!DOCTYPE.*?<html>.*?<body><p>/ims', '', $html); $html = str_replace('</p></body></html>', '', $html); return $html; } $s = []; $s[] = "hey buddy what's up script"; $s[] = "Hi Friend <script>alert('hello world');</script>"; $s[] = "<script src=\"http://jquery.com\">joyjoy</script>happy"; foreach($s as $t){ echo $t.' ==> '.remove_script_tags($t)."\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
hey buddy what's up script ==> hey buddy what's up script Hi Friend <script>alert('hello world');</script> ==> Hi Friend <script src="http://jquery.com">joyjoy</script>happy ==> happy

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:
43.43 ms | 402 KiB | 8 Q