Re: Duda sobre CLASES en PHP

From: Date: Fri, 24 Sep 2004 18:18:06 +0000
Subject: Re: Duda sobre CLASES en PHP
References: 1 2 3 4  Groups: php.general.es 
Request: Send a blank email to general-es+get-51512@lists.php.net to get a copy of this message
Gracias!!, un error de sintaxis que no ví. Edu T. ----- Original Message ----- From: "Manuel Grau Aracil" <manuelgrau@marca.es> To: <php-es@lists.php.net> Sent: Friday, September 24, 2004 8:14 PM Subject: Re: [PHP-ES] Duda sobre CLASES en PHP > Cuando accedes a una variable miembro de una clase, debes poner $ delante del > this, eso lo tienes bien, pero quita $ delante del nombre de la variable: > > $this->texto1 = $this->limpia("123456789",3); > $this->texto2 = $this->limpia("987654321",6); > > Asi como te lo pongo, seria correcto. Saludos. > > > <?php > > // POR QUE ESTE CODIGO ME SACA POR PANTALLA > > // "987654 987654" EN VEZ DE "123 987654 > > > > // ES COMO SI $this->$texto1 Y $this->$texto2 AL FINAL VALIESEN LO > > MISMO > > // ALGUIEN SABE PORQUE??? > > // SOY NUEVO EN ESTO DE LAS CLASS > > > > //********** CLASE PRUEBA *************** > > class prueba { > > var $texto1; > > var $texto2; > > //Limpia la cadena pasada como parámetro > > function limpia($cadena,$caracteres){ > > // Corta la cadena al nº que le dice $caracteres > > $cadena = substr($cadena,0,$caracteres); > > $cadena = str_replace("\'","&#39;",$cadena); > > $cadena = str_replace('\"',"&quot;",$cadena); > > $cadena = trim(stripslashes(strip_tags($cadena))); > > // Devuelve la cadena limpita > > return $cadena; > > } > > > > function textosvarios() { > > $this->$texto1 = $this->limpia("123456789",3); > > $this->$texto2 = $this->limpia("987654321",6); > > echo $this->$texto1." ".$this->$texto2; > > } > > } > > //********** FIN CLASE PRUEBA **************** > > $a = new prueba(); > > $a->textosvarios(); > > ?> > > > > Gracias!! > > > > Edu T > > > > -- > > PHP Spanish Localization Talk Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > ----------------------------------------------------------------- > Este correo ha sido enviado via MarcaMail - > http://www.marca.net/ > > -- > PHP Spanish Localization Talk Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general.es (#51512) next »