Re: setting member variables out of class
| From: | Mike Frazer | Date: | Wed, 31 Oct 2001 15:30:22 +0000 |
| Subject: | Re: setting member variables out of class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73030@lists.php.net to get a copy of this message | ||
I believe you would be getting a number echoed to the screen or dumpfile,
but you want the values, correct?
$telefono is declared as an array. Calling an echo statement on an array
won't give you the values of the array elements. In order to have them all
printed to screen, try:
foreach ($telefono as $tele) { // $tele is just a tempo variable, name it
what you want
print "$telefono<br>\n"; // <br> for screen formatting, \n for
source formatting
}
Mike
"Silvia Mahiques" <mahiques@posta.unizar.es> wrote in message
news:004401c16219$b50eb930$1a9cd29b@tscpc6...
Hello,
I want to set member variables out of their class. The code class is:
<?php
class translator {
var $nombre;
var $departamento;
var $despacho;
var $telefono;
var $correo_electronico;
var $pagina_personal;
function translator(){
$nombre = array("Nombre","Name");
$departamento = array("Departamento","Department");
$despacho = array("Despacho","Office");
$telefono = array("Teléfono","Phone");
$correo_electronico = array("Correo Electrónico","E-mail");
$pagina_personal = array("Página Personal","Personal HomePage");
}
}
?>
I access to this class from another php file and want to set this member
variable:
$c = new translator();
echo $c->telefono; /* this member isn't set but in constructor method
has been set*/
I have written too:
echo $c->$telefon;
echo "{$c->telefon}";
but is not correct.
Can anybody help me?
Thanks
Silvia Mahiques