Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Created October 29, 2009 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzmartin/221062 to your computer and use it in GitHub Desktop.
Save tzmartin/221062 to your computer and use it in GitHub Desktop.
<?php
answer();
say ("Welcome.");
$question_cnt = 1;
function ask_question($q)
{
switch ($q) {
case 1:
$event = ask('Do you like the number one?', array("choices" => "no(no),yes(yes),back(back)","onEvent" => create_function( '$event', "return $event->value;")));
break;
case 2:
$event = ask('Do you like the number two?', array("choices" => "no(no),yes(yes),back(back)","onEvent" => create_function( '$event', "return $event->value;")));
break;
case 3:
$event = ask('Do you like the number three?', array("choices" => "no(no),yes(yes),back(back)","onEvent" => create_function( '$event', "return $event->value;")));
break;
}
return $event;
}
do {
$event = ask_question($question_cnt);
say("You said: ".$event->value);
if ($event->value == 'back') {
$question_cnt -= 1
} else {
$question_cnt += 1
}
} while ($question_cnt < 4);
say ("Thank you. Goodbye.");
hangup();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment