PHP: creating (X) HTML output from the DOM - pros and cons?

I just started working with a new site, and I decided to use DOMImplementation to create a complete site.

What do you think about this, is it enough? I expect this to be a bit slower than the main printing method. I prefer the DOM because it provides more flexibility in constructing the final result, not to mention the more error-free XHTML. Anyway, I would like to at least compare the speed.

Could you recommend me some (possibly quite obvious) ideas to keep PHP code clean (i.e. keep HTML at a minimal level)?

+3
source share
2 answers

? , . , , , DOM-templating .

HTML--XHTML ; saveXML, , -IE- XHTML, saveHTML, HTML4. CDATA, style script, .

DOM- , JavaScript . , , PHP.

PHP- "" , , PHP, <?php if (condition) { ?>... <?php } ?>, XML " ". . . .

+2

Widget, , checkBox, textArea .. View/Controller addContent ($ aString). , -

$builder = new Widget();
$this->addContent($builder->textArea("Description", $description, 5, 100);
$this->addContent($builder->radioGroup("Platform", array("FreeBSD", "Linux", "Windows"), $platform, 100);

public function textArea($name, $value, $numLines, $width) {...}
public function radioGroup($title, $nameArray, $selectedValue, $width0 {...}
// etc.

HTML: . Widget HTML - .

+3

Source: https://habr.com/ru/post/1735226/


All Articles