Problems with PHP DOMDocument LoadHTML when parsing CDATA sections in Script tags

I get this error when trying to parse HTML with a script tag using the PHP DOMDocument class.

Warning: DOMDocument::loadHTML(): Unexpected end tag : style in Entity, line: 71 in /var/www/signage-dev/dynaml/includes/page.php on line 95

I even tried CDATA tags, but this led to the same error

My script tag

<script type="text/javascript">
//<![CDATA[
document.write('<style type="text/css"> .printBTN { display: inline; } </style>');
//]]>   
</script>

This snippet should show the print button when JavaScript is enabled. I don’t think that this is the most effective way to do this (previous developers created this), but even then I want to find a solution to this problem, as I may again encounter this problem in the future, and it may not be as easy fix like that.

+3
source share
1 answer

, , document.write()?

, php DOM , . , , - , , <\/script> <\/style>, , script.

+2

All Articles