Foros del Web » Programando para Internet » PHP »

Pasar objetos entre funciones ;-)

Estas en el tema de Pasar objetos entre funciones ;-) en el foro de PHP en Foros del Web. Holitas, jeje el caso es que estoy programando unas librerias para mi el programa PHP-EDDI-DEV, jeje como sabeis lo estoy haciendo en PHP-GTK y tengo ...
  #1 (permalink)  
Antiguo 23/05/2002, 11:49
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 5 meses
Puntos: 5
Pasar objetos entre funciones ;-)

Holitas, jeje el caso es que estoy programando unas librerias para mi el programa PHP-EDDI-DEV, jeje como sabeis lo estoy haciendo en PHP-GTK y tengo un problemilla, ya que no puedo tomar el valor de un objeto creado dentro de una funcion,
es decir tengo pro ejemplo

funcion crear(){

$objeto = new objeto;
$objeto->funcione_de_bojeto();

}

luego quiero cojer datos de ese objeto, pero no puedo hacerlo, en php no se peude hacer, pero estoy pensando en crear una clase donde cree las varaibles globalmente y luego poder hacer uso de ellas, pero bueno jeje si a alguien se le ocurriera algo k me lo dijera pls

<table style="border:1px solid black"><tr><td><center>
<embed width="88" height="144" src="http://www.alaplaya.com/~epplestun/yo.swf"></td></td><font face=verdana size=1>Ivan Rodriguez el poder es [B]PHP</p></td></tr></table>
  #2 (permalink)  
Antiguo 23/05/2002, 13:23
Avatar de Webstudio
Colaborador
 
Fecha de Ingreso: noviembre-2001
Ubicación: 127.0.0.1
Mensajes: 3.499
Antigüedad: 22 años, 5 meses
Puntos: 69
Re: Pasar objetos entre funciones ;-)

Lo que podés hacer es lo siguiente :

function crearInstanciaDe($objeto)
{
$obj = new $objeto;
return $obj;
}

Y lo podés llamar asi :

$c = crearInstanciaDe(&quot;GTK_Window&quot;);
$c-&gt;llamarMetodo();

Saludos.

<hr><font size=2 face="verdana">- Pablo Daniel Rigazzi (Webstudio)
<font size=1 color="#333333">COORDINADOR PROYECTO REGIONALIZACION ARGENTINA
Visita <a href="http://www.web-studio.com.ar" target="_blank">Web Studio</a> - Tutoriales Photoshop</fo
  #3 (permalink)  
Antiguo 23/05/2002, 13:58
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 5 meses
Puntos: 5
Re: Pasar objetos entre funciones ;-)

jeej podria ser muchas gracias, pero ya habia empezado con la clase y declarar todos los objetos en un array y este como es global pos ya ta muchas gracias pablo

<table style="border:1px solid black"><tr><td><center>
<embed width="88" height="144" src="http://www.alaplaya.com/~epplestun/yo.swf"></td></td><font face=verdana size=1>Ivan Rodriguez el poder es [B]PHP</p></td></tr></table>
  #4 (permalink)  
Antiguo 24/05/2002, 03:07
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 5 meses
Puntos: 5
Re: Pasar objetos entre funciones ;-)

jje Pablo lo hice mucho mas facil mira, aqui os dejo el codigo jeje de prueba que me monte VIVAN LOS OBJETOS

Código:
&lt;?php

dl(stristr(PHP_OS, &quot;WIN&quot;) ?  &quot;php_gtk.dll&quot; : &quot;php_gtk.so&quot;);

class objetos {

    var $gui;
    
    function objetos() {
    
            $this-&gt;gui = array();
    
    }
    
    function cerrar() {
    
      Gtk::main_quit();
      
    }
    
    function crear() {
    
      $this-&gt;gui['ventana'] = new GtkWindow();
      $this-&gt;gui['ventana']-&gt;set_usize(300,300);
      $this-&gt;gui['ventana']-&gt;connect('destroy',array( &amp;$this, 'cerrar'));
      $this-&gt;gui['caja'] = new GtkVBox();
      $this-&gt;gui['boton'] = new GtkButton('Aceptar');
      $this-&gt;gui['boton']-&gt;connect('clicked',array( &amp;$this, 'mostrar'));
      $this-&gt;gui['boton']-&gt;show();
      $this-&gt;gui['texto'] = new GtkText;
      $this-&gt;gui['texto']-&gt;set_editable(true);
      $this-&gt;gui['texto']-&gt;show();
      $this-&gt;gui['caja']-&gt;pack_start($this-&gt;gui['boton']);
      $this-&gt;gui['caja']-&gt;pack_end($this-&gt;gui['texto']);
      $this-&gt;gui['ventana']-&gt;add($this-&gt;gui['caja']);
      $this-&gt;gui['ventana']-&gt;show_all();
      Gtk::main();
      
    }
    
    function mostrar() {
    
      $palabras = $this-&gt;gui['texto']-&gt;get_chars(0,-1);
      echo $palabras;

    }
}

$objeto = new objetos;
$objeto-&gt;crear();
?&gt;
<table style="border:1px solid black"><tr><td><center>
<embed width="88" height="144" src="http://www.alaplaya.com/~epplestun/yo.swf"></td></td><font face=verdana size=1>Ivan Rodriguez el poder es [B]PHP</p></td></tr></table>
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 02:42.