private $titulos = array(); public function cargarOpcion($en, $tit) { $this->enlaces[] = $en; $this->titulos[] = $tit; } public function mostrar() { for ($f = 0; $f < count($this->enlaces); $f++) { echo '<a href="' . $this->enlaces[$f] . '">' . $this->titulos[$f] . '</a>'; echo "-"; } } } $menu1 = new Menu(); $menu1->cargarOpcion('http://www.facebook.com', 'Facebook'); $menu1->cargarOpcion('http://www.yahoo.com', 'Yhahoo'); $menu1->cargarOpcion('http://www.msn.com', 'MSN'); $menu1->mostrar(); class CabeceraPagina { private $titulo; private $ubicacion; public function inicializar($tit, $ubi) { $this->titulo = $tit; $this->ubicacion = $ubi; } public function graficar() { echo '<div style="font-size:40px;text-align:' . $this->ubicacion . '">';
/** * */ class Menu { private $enlaces = array(); private $titulos = array(); function cargarOpcion($en, $tit) { $this->enlaces[] = $en; $this->titulos[] = $tit; } public function mostrar() { /* echo "Array de enlaces <br />"; print_r($this->enlaces); echo "<br />"; print_r($this->titulos); */ for ($i = 0; $i < count($this->enlaces); $i++) { echo '<a href="' . $this->enlaces[$i] . '">' . $this->titulos[$i] . '</a> '; } } } $menu1 = new Menu(); $menu1->cargarOpcion("http://www.google.com", "Buscador Google"); $menu1->cargarOpcion("http://www.yahoo.com", "Buscador Yahoo"); $menu1->cargarOpcion("http://www.msn.com", "MSN"); $menu1->mostrar();
<?php /** * */ class Menu { private $enlaces = array(); private $titulos = array(); function cargarOpcion($en, $tit) { $this->enlaces[] = $en; $this->titulos[] = $tit; } public function mostrar() { /* * */ for ($i = 0; $i < count($this->enlaces); $i++) { echo '<a href="' . $this->enlaces[$i] . '">' . $this->titulos[$i] . '</a> '; } } } $menu1 = new Menu(); $menu1->cargarOpcion("http://www.google.com", "Buscador Google<br>"); $menu1->cargarOpcion("http://www.yahoo.com", "Buscador Yahoo<br>"); $menu1->cargarOpcion("http://www.msn.com", "MSN<br>"); $menu1->cargarOpcion("http://www.marca.com", "Marca<br>"); $menu1->mostrar();
<?php class Menu { private $enlaces = array(); private $titulos = array(); public function cargarOpcion($en, $tit) { $this->enlaces[] = $en; $this->titulos[] = $tit; } public function mostrar() { for ($f = 0; $f < count($this->enlaces); $f++) { echo '<a href="' . $this->enlaces[$f] . '">' . $this->titulos[$f] . '</a>'; echo "-"; } } } $menu1 = new Menu(); $menu1->cargarOpcion('http://www.google.com', 'Google'); $menu1->cargarOpcion('http://www.yahoo.com', 'Yhahoo'); $menu1->cargarOpcion('http://www.msn.com', 'MSN'); $menu1->mostrar(); // Implementar una clase que muestre una lista de hipervínculos en forma horizontal (básicamente un menú de opciones) ?>
<?php include './menu.php'; $menu1 = new Menu(); $menu1->cargarOpcion('http://www.marca.com', 'Marca'); $menu1->cargarOpcion('http://www.elpais.com', 'El Pais'); $menu1->cargarOpcion('http://www.elmundo.com', 'El Mundo'); $menu1->mostrar("horizontal"); echo '<br>'; $menu2 = new Menu(); $menu2->cargarOpcion('http://www.marca.com', 'Marca'); $menu2->cargarOpcion('http://www.elpais.com', 'El Pais'); $menu2->cargarOpcion('http://www.elmundo.com', 'El Mundo'); $menu2->mostrar("vertical");