We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

inline php

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
jbrohan
Posts: 19
Joined: Mon Nov 19, 2007 10:17 am
Location: Montreal Canada
Contact:

inline php

Post 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
John Brohan National Instruments LabVIEW expert in Montreal
Traders Micro "We connect all sorts of things to computers"
telemedicine applications
www.woundfollowup.com

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR example that uses inline php

Post 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
Last edited by support on Wed Jan 13, 2010 12:24 pm, edited 3 times in total.

jbrohan
Posts: 19
Joined: Mon Nov 19, 2007 10:17 am
Location: Montreal Canada
Contact:

Post 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
John Brohan National Instruments LabVIEW expert in Montreal
Traders Micro "We connect all sorts of things to computers"
telemedicine applications
www.woundfollowup.com

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR system clarification

Post 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

Post Reply