Código PHP:
Ver original<?php
require_once("form.class.php");
$form = new Form();
$form->iniciarForm("accion" , "post");
$form->agregarCampo("Nombre","text");
$form->agregarCampo("Apellido","text");
$form->agregarCampo("DNI","text");
$form->agregarCampo("Telefono","text");
$form->agregarCampo("enviar","submit", "enviar");
$form->terminarForm();
?>
Código PHP:
Ver original<?php
class Form{
public function iniciarForm($accion, $metodo){
print "<form action='" . $accion ."' method='" . $metodo . "' >";
}
public function agregarCampo($nombre, $tipo , $valor = null){
print "<label>" . $nombre . "</label><input type='". $tipo ."' id='" . $nombre . "' value='" . $valor . "' />";
}
public function terminarForm(){
print "</form>";
}
}
?>
Te hice algo muy sencillo orientado a objetos... es algo simple y facil, hay mil formas de mejorarlo pero eso ya te lo dejo a vos.