Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

Using $this when not in object context

Estas en el tema de Using $this when not in object context en el foro de Frameworks y PHP orientado a objetos en Foros del Web. Hola a todos, Soy nuevo en PHP y estoy teniendo problemas al pasar un objeto a otra clase... $p = new Product(array('product_id'=>$product_id)); $p->parents(); Dentro de ...
  #1 (permalink)  
Antiguo 28/01/2007, 11:12
 
Fecha de Ingreso: enero-2007
Mensajes: 1
Antigüedad: 17 años, 3 meses
Puntos: 0
Using $this when not in object context

Hola a todos, Soy nuevo en PHP y estoy teniendo problemas al pasar un objeto a otra clase...

$p = new Product(array('product_id'=>$product_id));
$p->parents();

Dentro de la clase Product, tengo entre otras estas funciones...
function parents()
{
return $this->tree()->parents();
}
function tree()
{
if ($this->tree === NULL)
{
$this->tree = new Tree;
$this->tree->node($this);
}
return $this->tree;
}

En la clase Tree...

public function node($o=NULL)
{
if ($o !== NULL)
{
if (is_object($o) && ($o instanceof Base))
{
$class = get_class($o);
if ($this->node !== NULL // AQUI ME DA EL PROBLEMA
...............
..........
}

EL ERROR ES...... Using $this when not in object context in......

Alguien me puede dar una pista? he estado probando diferentes cosas pero no consigo avanzar..

Muchas gracias.
  #2 (permalink)  
Antiguo 28/01/2007, 19:18
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Using $this when not in object context

Que tal nanus,

Si pudieras postear el codigo completo, te lo agradeceria, asi podria hubicar mas facil donde esta el error.

Saludos.
  #3 (permalink)  
Antiguo 31/01/2007, 15:50
 
Fecha de Ingreso: septiembre-2005
Mensajes: 142
Antigüedad: 18 años, 7 meses
Puntos: 3
Re: Using $this when not in object context

Uff creo que GatorV tiene razón en fin quizá el problema sea poner

Código PHP:
if ($this->tree->node!== NULL // AQUI ME DA EL PROBLEMA 
en vez de

Código PHP:
if ($this->node !== NULL // AQUI ME DA EL PROBLEMA 
por el poco código que veo he observado que has instanciado un objeto
Código PHP:
$this->tree = new Tree
así que creo que tienes el error ahi.

Por cierto felicidades GatorV ya eres colaborador por lo que veo jeje me alegro mucho la verdad es que estos foros tienen suerte de tener a gente como tu nos vemos
  #4 (permalink)  
Antiguo 31/01/2007, 21:09
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Using $this when not in object context

Pues todo un honor Casius, un saludo tambien para ti.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:34.