Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Would it be better to have all of my display functions return the HTML they generate, so that the main controller can just echo $page; or should the display files use raw HTML outside of PHP, which gets output as soon as it's read?</p> </blockquote> <p>One of the advantages of php is that the processing is similar to the output:</p> <p>So:</p> <pre><code>&lt;h1&gt; &lt;?= $myHeading; ?&gt; &lt;/h1&gt; </code></pre> <p>Is more clear than:</p> <pre><code>echo "&lt;h1&gt;$myHeading&lt;/h1&gt;"; </code></pre> <p>An even more than:</p> <pre><code>echo heading1($myHeading); //heading1() being an hypothethical user defined function. </code></pre> <p>Based on that I consider that it is better to in the view to have HTML and and just print the appropriate dynamic fields using php.</p> <p>In order to get finner control over the output you can use: ob_start as gurunu recommended.</p> <p>You could of course use any of the several php MVC frameworks out there. My prefered one, now is: <a href="http://www.solarphp.com/" rel="nofollow noreferrer" title="SolarPHP">Solarphp</a></p> <p>but <a href="http://framework.zend.com/" rel="nofollow noreferrer" title="Zend Framework">Zend Framework</a> and <a href="http://cakephp.org/" rel="nofollow noreferrer">Cakephp</a> could help you too.</p> <p>And finally if you don't want to use any framework You could still use a pretty slim templating engine: <a href="http://phpsavant.com/" rel="nofollow noreferrer" title="phpSavant">phpSavant</a>. That will save you a few headaches in the development of your view. th</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload