R
R
Robert Gard2020-05-20 01:06:36
Parsing
Robert Gard, 2020-05-20 01:06:36

Why does DIDOM library remove php code?

Greetings!
There was a problem with the php library for DIDOM parsing.

I am loading HTML from a local php file like this:

$document->loadHtml('front.php', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);


And then I output what was in the front.php file using $document->format()->html(LIBXML_NOEMPTYTAG);

And everything would be fine, but if the front.php file has a php code at the end and it does not have a closing tag ?>, then this php code will be deleted entirely.

That is, for example, if the front.php file contains the following content:
<div>
     <h1>Text</h1>
</div>
<?php
echo "test";

As you can see, there is no closing tag ?>in this file, and that is why after displaying the contents of this file by the html () method, there will be no php code at all:
<div>
     <h1>Text</h1>
</div>

But if you put down the closing tag ?>, then there will be no problems and everything will be displayed as it should. How to cancel such behavior? So that php code is not cut out despite the fact that the closing tag ?>is not affixed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2020-05-20
@xmoonlight

It's easier to add ("close" the tag) manually.
Changing behavior is unlikely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question