Page 1 of 1

inline php

Posted: Mon Nov 19, 2007 11:44 am
by jbrohan
Hello
can you show a small piece of vxml code that contains some php

for example

<prompt>
<?php echo "these words come from php"; ?>
</prompt>

does not do anything in my developer account.

Yours Sincerely
John

IVR example that uses inline php

Posted: Mon Nov 19, 2007 11:56 am
by support
Hi,

Here is a small IVR example that uses inline php. Note the php written in the <var> tags:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");

$customerid = 1000;
$age = 15;
?>

<vxml version="2.0">
	<form>
		<var name="customerid" expr="'<?php echo($customerid)?>'"/>
		<var name="age" expr="'<?php echo($age)?>'"/>
		<block>
			<prompt> Your customer identification number is <value expr="customerid"/>. </prompt>
 			<prompt> Your age is <value expr="age"/>. </prompt>
		</block>
	</form>
</vxml>
Hope this helps.

Regards,
Plum Support

Posted: Mon Nov 19, 2007 12:46 pm
by jbrohan
Hi
I appreciate the rapid turnaround.
I pasted the proposed text into a scratchpad and tried to validate it...
Validation Results:
Fatal Error at line 3, char 30
Message: Invalid document structure
scanFirst() failed

Sorry, I'm really new to Vxml. In regular HTML you can say <?php echo "this should print"; ?> and it gets inserted into the HTML stream to the browser.
Does it work the same way here?

Yours Sincerely
John

IVR system clarification

Posted: Mon Nov 19, 2007 1:00 pm
by support
Hi,

Yes, it does work the same way in VoiceXML as it does in HTML. However, in order to execute PHP documents you will need your own PHP server. The scratchpads are only meant to contain static VoiceXML, any PHP placed in them will not be executed. Any PHP you put in a scratchpad will just be read as VoiceXML and will cause IVR validation errors.

Regards,
Plum Support