Ver Mensaje Individual
  #17 (permalink)  
Antiguo 09/04/2008, 10:10
Avatar de alaintm
alaintm
 
Fecha de Ingreso: marzo-2007
Mensajes: 149
Antigüedad: 17 años, 2 meses
Puntos: 1
Re: Analisis de Clase y Herencia

Estuve revisando algo de documentación y lo que me haz indicado.

1. Cuando te refieres a propiedad lo que entiendo des pues de revisar la documentación es cuando declaro:
Código PHP:
public $variable
mientras que método es:
Código PHP:
public function nombre(){} 
2. Me recomiendas que no declare variable publicas ahí es donde me pierdo o es que no se debe abusar de ellas y si no es así como es que lo manejaría las propiedades, porque de esta forma lo veo y te pongo el ejemplo que estuve revisando:

We have added two things in the example below. First of all, we have added a new property by adding the line: "public $name". This gives our class a new public property called $name. The second thing we've done is change the drive() method, as it now prints the value of the $name property. As you can see we use $this->name to refer to the $name property.

The $this variable refers to the current instance, and must be used when you want to access a property or method from within the class.

The example below demonstrates the use of the $name property and the $this variable:
Código PHP:
<?php

Class MyCar {
        public 
$name;

        function 
drive() {
                echo 
'Vrooooom... ' $this->name;
        }
}

// Instance 1
$porsche = new MyCar();
$porsche->name 'Porsche';
$porsche->drive();
3. No entiendo lo de setters/getters.