Link to home
Start Free TrialLog in
Avatar of Richard Winnick
Richard Winnick

asked on

use php variables in simple xml

We are just learning vxml and are trying to use $_REQUEST to get a variable from the url and place it in a dom doc to create a simple xml/vxml output -

We have tried the following code but get a parse error -
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in xxxxxxxxxxxxxx.php on line 10 -

What are we missing -
Thanks in advance for the help

<?php
$doc = new DomDocument('1.0');
 $doc ="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
 $doc .="<vxml version = \"2.1\" >\n";
$doc .="<form id=\"mainDialog\">\n";
$doc .="<prompt> your caller id is <?php $_REQUEST['callerid'];?></prompt>\n";      
$doc .="</form>\n";
$doc .="</vxml>\n";
$sxe = new SimpleXMLElement($doc);
    echo $sxe->asXML();
?>
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

You'll need to concatenate the request:
$doc .="<prompt> your caller id is " . $_REQUEST['callerid'] . "</prompt>\n"; 

Open in new window

SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Winnick
Richard Winnick

ASKER

Chris provided initial insight and Ray elaborated in depth so owe both you guys our thanks and feel it's fair to split the points evenly -
Hope this is OK with all -
As always EE is the greatest -
Thanks
Richard