Page 1 sur 1

variable de variable.. ca existe ?

Posté : 26 juil. 2007, 15:13
par cyberio
bonjour à tous ceux qui sont pas en vacances.. comme moi :cry:
ma question est la suivante :
comment afficher une variable dont le nom est contenu dans une autre variable... :lol:

Code : Tout sélectionner

$test="ceci est un test" ..... $nomvariable="test"; echo $"$nomvariable"; /// oops marche pas :-(
merci d'avance :P

euuhhhh trouvé !
$$nomvariable.....
OK JE SORS :oops:

Posté : 26 juil. 2007, 15:18
par Genova
$var = 'toto';

echo $$var; // Correspond à echo $toto;

echo ${'je_suis_' . $var}; // Correspond à echo $je_suis_toto;

$var(); // Correspond à l'appel de fonction toto()

$object->$var; // Correspond ) $object->toto;
http://fr.php.net/manual/fr/language.va ... riable.php

Posté : 26 juil. 2007, 15:19
par cyberio
merci mec ;-)

Posté : 26 juil. 2007, 15:19
par d0m