Example #1
0
    {
        $this->nombre = $nom;
    }
    public function imprimir()
    {
        echo $this->nombre;
        echo '<br>';
    }
}
$per1 = new Persona();
$per1->inicializar('Juan');
$per1->imprimir();
?>
    <?php 
$per2 = new Persona();
$per2->inicializar('ana');
$per2->imprimir();
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 "-";
Example #2
0
<?php

class Persona
{
    private $nombre;
    public function inicializar($nom)
    {
        $this->nombre = $nom;
    }
    public function imprimir()
    {
        echo $this->nombre;
        echo '<br>';
    }
}
$per1 = new Persona();
$per1->inicializar('Juan');
$per1->imprimir();
$per2 = new Persona();
$per2->inicializar('Ana');
$per2->imprimir();
<?php

/**
* 
*/
class Persona
{
    private $nombre;
    public function inicializar($nom)
    {
        $this->nombre = $nombre;
    }
    public function imprimir()
    {
        echo $this->nombre;
        echo "<br />";
    }
}
//Anem a gastar la clase
$per1 = new Persona();
$per1->inicializar("Lucia");
$per1->imprimir();
Example #4
0
<?php

/**
 * 
 */
class Persona
{
    private $nombre;
    public function inicializar($nom)
    {
        $this->nombre = $nom;
    }
    public function imprimir()
    {
        echo $this->nombre;
        echo "<br />";
    }
}
//Anem a gastar la clase
$per1 = new Persona();
$per1->inicializar("Alex");
$per1->imprimir();
?>