concaténation de variables

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : concaténation de variables

par Neophyte » 03 mars 2006, 16:01

Merci à tous les deux.

La fonction constant() a résolue mon problème.

Encore merci et bonne journée.
:D

$def=constant($def);  
$b="<img src=\"images/loupe.PNG\" border=\"0\" width=\"20\" height=\"20\" alt=\"".$def."\"> " ;

par ouckileou » 03 mars 2006, 15:55

ou avec la fonction constant
<?php
define ("DEF_COMP1", "test A....");
define ("DEF_COMP2", "test b....");
define ("DEF_COMP3", "test c....");
define ("DEF_COMP4", "test D....");
define ("DEF_COMP5", "test E...");


for ($i=1; $i<6; $i++) {
	$def = DEF_COMP.$i;
	echo "<br /><br /> $i : ";
	echo constant($def);
}
?>

par Hermès » 03 mars 2006, 15:26

echo eval("echo $def;");

concaténation de variables

par Neophyte » 03 mars 2006, 15:18

Bonjour,

C'est sans doute simple quand on le sait... mais je sèche.

Merci.
:?

<?

define ("DEF_COMP1", "test A....");
define ("DEF_COMP2", "test b....");
define ("DEF_COMP3", "test c....");
define ("DEF_COMP4", "test D....");
define ("DEF_COMP5", "test E...");


  for ($i=1; $i<6; $i++)
     {
$def="";
  $def.="DEF_COMP".$i;
echo "<br><br>"; 
echo $def;

}

?>
echo $def me donne :

DEF_COMP1

DEF_COMP2

DEF_COMP3

DEF_COMP4

DEF_COMP5

Alors que je souhaiterais :

test A....
test B....
test C....
test D....
test E....