Is it better to sprinkle PHP blocks in a document or use PHP DOM with anchors? -


What is the best way to create an HTML document using PHP? I feel that when the page contains dynamically generated content, & lt ;? Php? & Gt; The use of blocks becomes quite dirty. I was thinking of using PHP DOM manipulation library to insert dynamic content into "anchor" in the document. The result will be in the cleaner document layout because all PHP is in one place and the HTML is in each other.

What is readability / execution professional / misfortune to use PHL blocks using PHP DOM manipulation? What is acceptable practice of creating HTML documents with PHP?

Before long, I believed the "anchor" was the way to go I had a smart templates in those days Use the engine to do yourself a favor, and leave that step you see ... you will soon find you need some basic control structures in your pages. Here is a small loop, a small conditional is there before you know it, you may be implementing your own little programming language to parse those anchors.

It happens when the morning starts to rise that PHP is really a powerful firearms language. This approach has taken many frameworks these days. I would recommend taking a look at Zend_View of Zend Framework. They do nifty little things where they use output buffering to capture the results of a PHP page. This gives them interesting content such as assigning data to an object and retrieving it in the $> -> template.

What do you want to do in your pages ... Separation of anxiety, which divides your 'presentation' with your business logic, this is always a good idea and if you yourself If the presentation is restricted to logic, then it is naturally such that your pages will only be the required PHP for you. As mentioned above .. Loops of a time, if there is anything, it should be.

See also: MVC pattern


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -