Very simple code doesnt work. Why?

Alles, was PHP betrifft, kann hier besprochen werden.

Very simple code doesnt work. Why?

Postby estudiante » 20. May 2009 10:44

Code: Select all
class Two_dimensions
 {
    // Attributes
    private $two_dimensions_array = null;
    
    // Constructor
    function __construct()
    {
       this->two_dimensions_array = array ("cero" => "Hola");
    }
    
    // Methods
    function print_it()
    {
        $counter = count(this->two_dimensions_array);
       print " $counter ";
       print_r(this->two_dimensions_array);
    }
 }




// Thank you!
estudiante
 
Posts: 15
Joined: 04. May 2009 10:08

Re: Very simple code doesnt work. Why?

Postby Xardas der Dunkle » 20. May 2009 11:03

Told us in a complete sentense, what doesn't work ...
Btw. this board has [code][/code]-Tags and they want to be used!
User avatar
Xardas der Dunkle
 
Posts: 482
Joined: 09. March 2008 19:40
Location: /var/www

Re: Very simple code doesnt work. Why?

Postby newbie2244 » 26. May 2009 20:05

Hola, te saludo un novicio/a de EEUU-

? Porque no leyes lo que esta escrito en http://www.php.net/manual/en/language.types.array.php o http://www.php.net/manual/es/language.types.array.php ? Los dados ejemplos son claros - te ayuda mucho.

(Disculpeme por favor pero tengo solo una tecla inglesa.)

!Mucha suerte!
newbie2244
 
Posts: 49
Joined: 20. February 2009 22:39

Re: Very simple code doesnt work. Why?

Postby Sekundentakt » 06. July 2009 21:38

I'm not sure, but I think you have forgotten the dollar-signs in front of your "this"'s.

The corrected code:
Code: Select all
class Two_dimensions
{
   // Attributes
   private $two_dimensions_array = null;
   
   // Constructor
   function __construct()
   {
      $this->two_dimensions_array = array ("cero" => "Hola");
   }
   
   // Methods
   function print_it()
   {
        $counter = count($this->two_dimensions_array);
      print " $counter ";
      print_r($this->two_dimensions_array);
   }
}
Sekundentakt
 
Posts: 6
Joined: 06. July 2009 21:03


Return to PHP

Who is online

Users browsing this forum: No registered users and 15 guests