Is it bad to break out of php inside a function? -
Is it bad to break out of php inside a function? -
more point, 1 of these faster or considered 'better' other?
function name_field($name){?> <div class="input-wrap"> <label for="name">name:</label> <input type="text" id="name" value="<?php echo $name; ?>"/> </div> <?php }
compared to:
function name_field($name){ $output = '<div class="input-wrap">'; $output .= '<label for="name">name:</label>'; $output .= '<input type="text" id="name" value="' . $name . '"/>'; $output .= '</div>'; echo $output; }
what preference ...
use mustache , save name_field.html
<div class="input-wrap"> <label for="name">name:</label> <input type="text" id="name" value="{{name}}"/> </div>
and
function name_field($name) { echo $this->m->render("name_field", array('name' => $name)); }
this seperates html php , larger examples comes in extremely handy
php
Comments
Post a Comment