Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.63 KB | None | 0 0
  1. <?php
  2. function tag($tag, $content=' ', $attribut=array(), $before='', $after=''){
  3.     $str='';
  4.     foreach($attribut as $name => $value){
  5.       $str.=" $name='$value'";
  6.     }
  7.     if(empty($content)){
  8.       return $before."<".$tag.$str.">".$after;
  9.     }
  10.     else{
  11.       return $before."<".$tag.$str.">".$content."</".$tag.">".$after;
  12.     }
  13. }
  14.  
  15. function label($content,$attribut){
  16.     return tag('label',$content,$attribut,'','');
  17. }
  18.  
  19. function sel($name,$opts=array(),$n,$attribut=array()){
  20.   $content='';
  21.   $value='';
  22.   $attr['value']=$value;
  23.     foreach($opts as $value => $str){
  24.       if($n==$value){
  25.       $content.="\n".tag('option selected', $value, array('value'=>$value))."\n";
  26.     }
  27.     else{
  28.       $content.="\n".tag('option', $value, array('value'=>$value))."\n";
  29.     }
  30.     }
  31.     $attribut['name']=$name;
  32.     return tag('select',$content,$attribut)."\n";
  33. }
  34.  
  35. function table($content='', $attribut=array(), $before='', $after=''){
  36.     return tag('table', $content, $attribut, $before, $after);
  37. }
  38.  
  39. function tr($content){
  40.   return tag('tr',$content);
  41. }
  42.  
  43. function td($content=''){
  44.   return tag('td', $content);
  45. }
  46.  
  47. function tablemult($n){
  48.   $content='';
  49.   for($i=1;$i<11;$i++){
  50.     $res = $i*$n;
  51.     $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>";
  52.   }
  53.   return tag('table',$content);
  54. }
  55.  
  56. function paragraphe($balise,$sujet=' '){
  57.   $tag=$balise;
  58.   $content=$sujet;
  59.   return tag($tag,$content);
  60. }
  61.  
  62. function input($content,$type='',$value='',$name='',$attributs=array()){
  63.   $attributs['type']=$type;
  64.   $attributs['value']=$value;
  65.   $attributs['name']=$name;
  66.   return tag('input',$content,$attributs);
  67. }
  68.  
  69. function title($sujet1=' '){
  70.   $content=$sujet1;
  71.   return tag('title',$content);
  72. }
  73.  
  74. function lien($target, $text, $attributs=array()){
  75.     $attributs['href']=$target;
  76.   return tag('a', $text, $attributs);
  77. }
  78.  
  79. function form($content, $method='POST', $action="#", $attribut=array()){
  80.     $attribut['method']=$method;
  81.     $attribut['action']=$action;
  82.  
  83.     return tag('form',$content,$attribut);
  84. }
  85.  
  86. /*function OuvrirTag($tag, $content=' ', $attribut=' ', $method=' '){
  87.     if(empty($content)){
  88.       $res= "<$tag $attribut $method>";
  89.     }
  90.     else{
  91.       $res= "<$tag $attribut $method> $content";
  92.     }
  93.     return $res;
  94. }
  95.  
  96. function FermerTag($tag){
  97.     $res= "</$tag>";
  98.     return $res;
  99. }
  100.  
  101. function formDeb($action, $method){
  102.     $action='action='.$action;
  103.     $method='method='.$method;
  104.     return OuvrirTag('form',' ',$action,$method);
  105. }
  106.  
  107. function formFin(){
  108.     return FermerTag('form');
  109. }*/
  110.  
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement