Advertisement
niwdeyen

Ejemplo Clase PHP

Nov 22nd, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. https://youtu.be/3fHB5fZcaG8
  2.  
  3. <?php
  4. class hiperv
  5. {
  6.     public $urls=array();
  7.     public $titulos=array();
  8.     public $contaurl;
  9.    
  10.     public function almacenarhiperv($ur,$ti)
  11.     {
  12.         $this->urls[] = $ur;
  13.         $this->titulos[] = $ti;
  14.     }
  15.    
  16.     public function cuantoshiperv()
  17.     {
  18.         $this->contaurl=count($this->urls);
  19.        
  20.    
  21.     }  
  22.    
  23.     public function mostrarhorizontal()
  24.     {
  25.         $i=0;
  26.         foreach($this->urls as $u)
  27.         {
  28.             echo "<a href=".$u.">".$this->titulos[$i]."</a>  ";
  29.             $i++;    
  30.         }
  31.     }
  32.    
  33. }
  34.  
  35. $hiper1=new hiperv();
  36. $hiper1->almacenarhiperv('www.google.com','Buscador super wow');
  37. $hiper1->almacenarhiperv('www.bing.com','Buscador normalito');
  38. $hiper1->almacenarhiperv('www.terra.com','Pagina rara');
  39. $hiper1->cuantoshiperv();
  40. echo $hiper1->contaurl;
  41. $hiper1->mostrarhorizontal();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement