1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| class champ
{
private $champ;
function __construct($type, $name, $value)
{
$this->champ = '<input type="' . $type . '" name="' . $name . '" value="' . $value . '"';
}
function longMax($n)
{
$this->champ .= ' maxlength="' . $n . '"';
}
function nbCar($n)
{
$this->champ .= ' size="' . $n . '"';
}
function retour()
{
return $this->champ . "/>\n";
}
}
class form extends champ
{
private $champ = array();
private $form;
private $fileType = false;
function __construct($action = URI, $methode='post')
{
$this->form = '<form action="' . $action . '" method="' . $methode . '"';
}
function champText($name, $value='')
{
$this->champ[$name] = new champ('text', $name, $value);
return $this->champ[$name];
}
function champPasswd($name)
{
$this->champ[$name] = new champ('password', $name, $value);
return $this->champ[$name];
}
function affichage()
{
$this->form .= "/>\n";
foreach( $this->champ as $name => $obj )
$this->form .= $this->champ[$name]->retour() ;
$this->form .= '</form>';
return $this->form;
}
}
$form = new form();
$pseudo = $form->champText('pseudo');
$pseudo->longMax(15);
$pseudo->nbCar(15);
$passwd = $form->champPasswd('passwd');
echo $form->affichage(); |
Partager