Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function tag($tag, $content=' ', $attribut=array(), $before='', $after=''){
- $str='';
- foreach($attribut as $name => $value){
- $str.=" $name='$value'";
- }
- if(empty($content)){
- return $before."<".$tag.$str.">".$after;
- }
- else{
- return $before."<".$tag.$str.">".$content."</".$tag.">".$after;
- }
- }
- function label($content,$attribut){
- return tag('label',$content,$attribut,'','');
- }
- function sel($name,$opts=array(),$n,$attribut=array()){
- $content='';
- $value='';
- $attr['value']=$value;
- foreach($opts as $value => $str){
- if($n==$value){
- $content.="\n".tag('option selected', $value, array('value'=>$value))."\n";
- }
- else{
- $content.="\n".tag('option', $value, array('value'=>$value))."\n";
- }
- }
- $attribut['name']=$name;
- return tag('select',$content,$attribut)."\n";
- }
- function table($content='', $attribut=array(), $before='', $after=''){
- return tag('table', $content, $attribut, $before, $after);
- }
- function tr($content){
- return tag('tr',$content);
- }
- function td($content=''){
- return tag('td', $content);
- }
- function tablemult($n){
- $content='';
- for($i=1;$i<11;$i++){
- $res = $i*$n;
- $content.=tr(td($n).td('x').td($i).td('=').td($res)); //correspond à "<tr><td>$n</td><td>x</td><td>$i</td><td>=</td><td>$res</td></tr>";
- }
- return tag('table',$content);
- }
- function paragraphe($balise,$sujet=' '){
- $tag=$balise;
- $content=$sujet;
- return tag($tag,$content);
- }
- function input($content,$type='',$value='',$name='',$attributs=array()){
- $attributs['type']=$type;
- $attributs['value']=$value;
- $attributs['name']=$name;
- return tag('input',$content,$attributs);
- }
- function title($sujet1=' '){
- $content=$sujet1;
- return tag('title',$content);
- }
- function lien($target, $text, $attributs=array()){
- $attributs['href']=$target;
- return tag('a', $text, $attributs);
- }
- function form($content, $method='POST', $action="#", $attribut=array()){
- $attribut['method']=$method;
- $attribut['action']=$action;
- return tag('form',$content,$attribut);
- }
- /*function OuvrirTag($tag, $content=' ', $attribut=' ', $method=' '){
- if(empty($content)){
- $res= "<$tag $attribut $method>";
- }
- else{
- $res= "<$tag $attribut $method> $content";
- }
- return $res;
- }
- function FermerTag($tag){
- $res= "</$tag>";
- return $res;
- }
- function formDeb($action, $method){
- $action='action='.$action;
- $method='method='.$method;
- return OuvrirTag('form',' ',$action,$method);
- }
- function formFin(){
- return FermerTag('form');
- }*/
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement