Hello. There is a code:

$postdata = '<?xml version="1.0" encoding="utf-8" ?> <package login="login" password="password"> <message> <msg recipient="СЮДА_ПЕРЕМЕННУЮ" sender="mail" validity_period="86400">И_СЮДА_ПЕРЕМЕННУЮ</msg> </message> </package>'; 

How can you add php variable to images like this?

  • read - PHP string concatenation - Bookin
  • Just like in html, isn't it? '. $ peremennaja.' - humster_spb
  • I just did not even consider this option. Thought XML is something: D - iKey

2 answers 2

 $variable = 'Значение переменной'; $variable2 = 'Значение второй переменной'; $postdata = '<?xml version="1.0" encoding="utf-8" ?> <package login="login" password="password"> <message> <msg recipient="' . $variable . '" sender="mail" validity_period="86400">' . $variable2 . '</msg> </message> </package>'; 

The second option:

 $variable = 'Значение переменной'; $variable2 = 'Значение второй переменной'; $postdata = sprint('<?xml version="1.0" encoding="utf-8" ?> <package login="login" password="password"> <message> <msg recipient="%s" sender="mail" validity_period="86400">%s</msg> </message> </package>', $variable, $variable2); 

The third option:

 $variable = 'Значение переменной'; $variable2 = 'Значение второй переменной'; $postdata = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> <package login=\"login\" password=\"password\"> <message> <msg recipient=\"$variable\" sender=\"mail\" validity_period=\"86400\">$variable2</msg> </message> </package>"; 

    Something like this:

     $postdata = '<?xml version="1.0" encoding="utf-8" ?> <package login="login" password="password"> <message> <msg recipient="'.$variable1.'" sender="mail" validity_period="86400">'.$variable2.'</msg> </message> </package>';