Jump to content

Archived

This topic is now archived and is closed to further replies.

spongebobusa

[Solved] Variables inside of <<<XML XML;

Recommended Posts

I currently have this:

[code]$xmlDoc =<<<XML
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>123456789</AccessLicenseNumber>
</AccessRequest>
XML;[/code]

How can I substitute use a variable inside of a <<<XML XML.  For instance, I want to use $number rather than 123456789.

Share this post


Link to post
Share on other sites
<AccessLicenseNumber>123456789</AccessLicenseNumber>

<?php
$number="123456789";
?>
Just add that to the script and I'm pretty sure that would replace the access license number to $number. When you want to use that number just put
<?php
echo $number;
?>
And that number will come up where ever you put it.

Hope that helps!

Share this post


Link to post
Share on other sites
That won't do it.

This will:
[code]
<?php
$licencenumber = 123456789;
$xmlDoc =<<<XML
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>$licencenumber</AccessLicenseNumber>
</AccessRequest>
XML;
?>[/code]

Heredoc (<<) will expand vars as if you were using double quotes. Alternitively, you  could look up XML entities.

Share this post


Link to post
Share on other sites
I swear I tried that!  ;D But it now works!  Thanks for the help.

[quote author=448191 link=topic=105448.msg421288#msg421288 date=1156406815]
That won't do it.

This will:
[code]
<?php
$licencenumber = 123456789;
$xmlDoc =<<<XML
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>$licencenumber</AccessLicenseNumber>
</AccessRequest>
XML;
?>[/code]

Heredoc (<<) will expand vars as if you were using double quotes. Alternitively, you  could look up XML entities.
[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.