本文整理汇总了PHP中answer函数的典型用法代码示例。如果您正苦于以下问题:PHP answer函数的具体用法?PHP answer怎么用?PHP answer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了answer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendTestValues
public function sendTestValues($id, $type, $flag)
{
// Test setting the question to answered
$_POST['type'] = $type;
$_POST['id'] = $id;
$_POST['flag'] = $flag;
include_once "../../Incognito/instr/scripts/answer_question.php";
answer($type, $id, $flag);
}
示例2: gameIntro
function gameIntro()
{
narrate(["This history starts in one dark night!"]);
dialog("Unknown Man", ["Hello.ÿ.ÿ.ÿ", "How are you doing?", "Have you heard about the last news from the Capital City?", "I think that is time to you know about it!", "I'm an old friend of your father.", "I've meet her before his death! So, i need to say something to you.ÿ.ÿ.ÿ", "It's very important! You have time to talk right now?"]);
answer(["Sorry, i know you?" => function () {
dialog("Unknown Man", ["Yes... And no!", "The last time we talk, you were a little boy!", "I think that you just don't remember!"]);
answer(["Ok. I have time now, continue please." => function () {
unknownManIntroduction();
}, "Really? I don't care! Get lost bitch!" => function () {
killedBy("Unknown Man");
}]);
}, "Sure, go on!" => function () {
unknownManIntroduction();
}, "Get lost, bitch!" => function () {
killedBy("Unknown Man");
}]);
}
示例3: answer
<?php
answer();
// ask for a single digit
$result = prompt("Hello. Please enter any single digit", array("choices" => "[1 DIGIT]"));
if ($result->name == 'choice') {
say("Great, you said " . $result->value);
}
// ask for a 5 digit long ZIP code
$result = prompt("Hello. Please enter your 5 digit ZIP code", array("choices" => "[5 DIGITS]"));
if ($result->name == 'choice') {
say("Great, you said " . $result->value);
}
// Digits work with speech or touch-tone input...
$result = prompt("Hello. Please say or enter your 5 digit ZIP code", array("choices" => "[5 DIGITS]"));
if ($result->name == 'choice') {
say("Great, you said " . $result->value);
}
// ask for 1 to 6 digit long an account ID
$result = prompt("Please enter your account ID followed by the pound key.", array("choices" => "[1-6 DIGITS]"));
if ($result->name == 'choice') {
say("Great, you said " . $result->value);
}
// ask for a US phone number (7 digits without area code, 10 digits with)
$result = prompt("Please enter your 7 to 10 digit U.S. phone number", array("choices" => "[7-10 DIGITS]"));
if ($result->name == 'choice') {
say("Great, you said " . $result->value);
}
// digit collection also supports all other prompt properties and event handlers
_log("\$***********************result name " . $result->name);
while ($result->name != 'hangup') {
示例4: pg_query
$result = pg_query($GLOBALS["conn"], $query);
$row = pg_fetch_row($result);
if ($row[0] === md5($answer)) {
return array('state' => "Correcto", 'box' => "#box-answer-profile");
} else {
$GLOBALS["estado"] = 1;
return array('state' => "Incorrecto", 'box' => "#box-answer-profile", 'errorBox' => "#error-answer-profile", 'error' => "La respuesta es incorrecta.");
}
} else {
$GLOBALS["estado"] = 1;
return array('state' => "Incorrecto", 'box' => "#box-answer-profile", 'errorBox' => "#error-answer-profile", 'error' => "Debe tener al menos 1 caracter.");
}
}
function newanswer($newanswer)
{
if (strlen($newanswer) > 0) {
return array('state' => "Correcto", 'box' => "#box-new-answer-profile");
} else {
$GLOBALS["estado"] = 1;
return array('state' => "Incorrecto", 'box' => "#box-new-answer-profile", 'errorBox' => "#error-new-answer-profile", 'error' => "Debe tener al menos 1 caracter.");
}
}
$array_data[] = answer($answer);
$array_data[] = newanswer($newanswer);
if ($estado == 0) {
$answerTemp = md5($newanswer);
$query = "update personas set respuestaseg='{$answerTemp}' where idPersona='{$user}'";
$result = pg_query($conn, $query);
}
echo json_encode($array_data);
}
示例5: answer
<?php
require_once "./connect.php";
//echo json_encode(answer($link));
echo answer($link);
function answer($link)
{
$query = "SELECT * FROM sit_place";
if (!($result = mysqli_query($link, $query))) {
die('Error search passenger id: ' . mysqli_error($link));
}
$ret = "";
while ($row = mysqli_fetch_assoc($result)) {
$ret .= '<section class="3u 6u(narrower)"><label>
<input type="checkbox" name="sitplace[]" value="' . $row["name"] . '">' . $row["name"] . '</label></section>';
}
return $ret;
}
示例6: get_text
<label for="answer"><?php
echo get_text('Answer');
?>
: </label><input type="text" name="answer" /><br />
<input type="submit" value="<?php
echo get_text('Answers');
?>
" name="answer_question"/>
</form>
</aside>-->
<?php
if (isset($_POST['answer_question'])) {
$question = $_POST['question'];
$poll = $_POST['poll'];
$answer = $_POST['answer'];
answer($poll, $question, $answer);
}
?>
<!--<aside class="bottomSidebar">
<h2><?php
echo get_text('Preferences');
?>
</h2>
<form method="post" action="<?php
$_SERVER['PHP_SELF'];
?>
">
<label for="me">Ik ben: </label>
<select name="me">
<option value=""><?php
echo get_text('Choose_a') . ' ' . strtolower(get_text('User_as_participant'));
示例7: listOptions
// turn the contacts into a comma seperated list of options for each contact (simple grammar)
function listOptions($theContacts)
{
$s = '';
foreach ($theContacts as $index => $contact) {
if ($s != '') {
$s .= ", ";
}
$s .= $index . " (" . $contact['nameChoices'] . ")";
}
return $s;
}
// -----------
// start
// -----------
// define the list of contacts
$contacts = array("nicole" => array("nameChoices" => "Nicole, Nicole Williams", "number" => "12067927251"), "april" => array("nameChoices" => "April, April Smith", "number" => "14129272367"), "gina" => array("nameChoices" => "Gina, Gina Anderson", "number" => "17135744782"));
// answer the phone and play the initial greeting
answer(30);
say("hello, and thank you for calling.");
// prompt the user for the name of the person they desire
$event = ask("Who would you like to call? Just say " . listNames($contacts), array("repeat" => "3", "timeout" => "7", "choices" => listOptions($contacts), "onTimeout" => create_function('$event', 'say( "I\'m sorry, I didn\'t hear anything." );'), "onBadChoice" => create_function('$event', 'say( "I\'m sorry, I didn\'t understand what you said." );')));
// if they made a choice, transfer to that person
if ($event->name == 'choice') {
say("ok, you said " . $event->value . ". Please hold while I transfer you.");
$ne = transfer("tel:+" . $contacts[$event->value]['number'], array("answerOnMedia" => false, "callerID" => "14074181800", "timeout" => 60.3456, "playrepeat" => 3, "playvalue" => "Ring... Ring... Ring...", "choices" => "1,2,3,4,5,6,7,8,9,0,*,#", "onSuccess" => create_function('$event', '_log("*********transfered to: " . $event->value->calledId);'), "onError" => create_function('$event', '_log("*********transfer error");'), "onTimeout" => create_function('$event', '_log("*********transfer timeout");'), "onCallFailure" => create_function('$event', '_log("*********transfer failed");'), "onChoice" => create_function('$event', '_log("*********transfer canceled");')));
_log("transfer event.name = " . $ne->name);
_log("transfer event.value = " . $ne->value);
say("Goodbye");
}
hangup();
示例8: testLife_the_universe_and_everything
public function testLife_the_universe_and_everything()
{
$this->assertEquals(42, answer());
}
示例9: PHPSHOP_error
@mysql_connect($SysValue['connect']['host'], $SysValue['connect']['user_db'], $SysValue['connect']['pass_db']) or @die("" . PHPSHOP_error(101, $SysValue['my']['error_tracer']) . "");
mysql_select_db($SysValue['connect']['dbase']) or @die("" . PHPSHOP_error(102, $SysValue['my']['error_tracer']) . "");
$pay_for = $_REQUEST['pay_for'];
$new_uid = UpdateNumOrder($pay_for);
$key = $SysValue['onpay']['onpay_key'];
if ($_REQUEST['type'] == 'check') {
$order_amount = $_REQUEST['order_amount'];
$order_currency = $_REQUEST['order_currency'];
$md5 = $_REQUEST['md5'];
// Приверяем сущ. заказа
$sql = "select uid from " . $SysValue['base']['table_name1'] . " where uid='{$new_uid}'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$uid = $row['uid'];
if ($uid == $new_uid) {
echo answer($_REQUEST['type'], 0, $pay_for, $order_amount, $order_currency, 'OK');
//Отвечаем серверу OnPay, что все хорошо, можно принимать деньги
} else {
echo 'Bad check request';
}
}
if ($_REQUEST['type'] == 'pay') {
$onpay_id = $_REQUEST['onpay_id'];
$pay_for = $_REQUEST['pay_for'];
$order_amount = $_REQUEST['order_amount'];
$order_currency = $_REQUEST['order_currency'];
$balance_amount = $_REQUEST['balance_amount'];
$balance_currency = $_REQUEST['balance_currency'];
$exchange_rate = $_REQUEST['exchange_rate'];
$paymentDateTime = $_REQUEST['paymentDateTime'];
$md5 = $_REQUEST['md5'];
示例10: testAnswer
public function testAnswer()
{
$this->assertEquals(6 * 9, answer());
}
示例11: answer
<?php
function answer() : int
{
return 42;
}
var_dump(answer());
示例12: answer
$dbbt->query($qv);
}
//Создаем запись о заказе с указаным invoiceId или обновляем статус заказа
$qv = "INSERT INTO `#__{vm}_orders_yandex_money_invoices` \n\t\t\t\t\t\t\t\tVALUES (\n \t'" . $order_invoice . "',\n '" . $order_id . "',\n '" . $sum . "',\n '" . ($ym_action == 'paymentAviso' ? YM_PAYMENT_STATUS : YM_CHECK_STATUS) . "'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE `order_status`='" . ($ym_action == 'paymentAviso' ? YM_PAYMENT_STATUS : YM_CHECK_STATUS) . "'\n\t\t\t\t\t";
$dbbt->query($qv);
$ps_order->order_status_update($d);
} else {
$qv = "SELECT `order_id`, `invoice_id`, `order_status`\n\t\t\t\t\t\t\t\tFROM `#__{vm}_orders_yandex_money_invoices`\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t`invoice_id`='" . $order_invoice . "'\n\t\t\t\t\t\t\t\t\tAND `order_id`='" . $order_id . "'\n\t\t\t\t\t\t\t\t\tAND `order_total`>='" . $sum . "'\n\t\t\t\t\t\t\t\t\tAND `order_status`='" . ($ym_action == 'paymentAviso' ? YM_PAYMENT_STATUS : YM_CHECK_STATUS) . "'\n\t\t\t\t\t";
$dbbt->query($qv);
$dbbt->next_record();
if ($dbbt->num_rows() == 1) {
//Отвечаем серверу Яндекс.Денег, что все хорошо, такой заказ существует и в нужном статусе
$rezult = answer($ym_action, $ym_shopID, $order_invoice, 0);
} else {
//Отвечаем серверу Яндекс.Денег, кодом 100 - Отказ в приеме перевода с заданными параметрами. Оператор считает ошибку окончательной и не будет осуществлять перевод.
$rezult = answer($ym_action, $ym_shopID, $order_invoice, 100);
}
}
} else {
//Отвечаем серверу Яндекс.Денег, кодом 1 - Несовпадение подписи (или хеша), неверный ключ подписи. Оператор считает ошибку окончательной и не будет осуществлять перевод.
$rezult = answer($ym_action, $ym_shopID, $order_invoice, 1);
$error = 1;
}
} else {
//Отвечаем серверу Яндекс.Денег, кодом 666 - Да, такой ошибки скорее всего нет, ну и ладно. Платеж то все-равно не прошел. Ну и хрен с ним.
$rezult = answer($ym_action, $ym_shopID, $order_invoice, 666);
$error = 1;
}
}
echo $rezult;
}
示例13: process_api_request
function process_api_request()
{
$rezult = '';
$error = '';
//проверяем чек запрос
if ($_REQUEST['type'] == 'check') {
//получаем данные, что нам прислал чек запрос
$order_amount = $_REQUEST['order_amount'];
$order_currency = $_REQUEST['order_currency'];
$pay_for = $_REQUEST['pay_for'];
$md5 = $_REQUEST['md5'];
//выдаем ответ OK на чек запрос
$rezult = answer($_REQUEST['type'], 0, $pay_for, $order_amount, $order_currency, 'OK');
}
//проверяем запрос на пополнение
if ($_REQUEST['type'] == 'pay') {
$onpay_id = $_REQUEST['onpay_id'];
$pay_for = $_REQUEST['pay_for'];
$order_amount = $_REQUEST['order_amount'];
$order_currency = $_REQUEST['order_currency'];
$balance_amount = $_REQUEST['balance_amount'];
$balance_currency = $_REQUEST['balance_currency'];
$exchange_rate = $_REQUEST['exchange_rate'];
$paymentDateTime = $_REQUEST['paymentDateTime'];
$md5 = $_REQUEST['md5'];
//производим проверки входных данных
if (empty($onpay_id)) {
$error .= "Не указан id<br>";
} else {
if (!is_numeric(intval($onpay_id))) {
$error .= "Параметр не является числом<br>";
}
}
if (empty($order_amount)) {
$error .= "Не указана сумма<br>";
} else {
if (!is_numeric($order_amount)) {
$error .= "Параметр не является числом<br>";
}
}
if (empty($balance_amount)) {
$error .= "Не указана сумма<br>";
} else {
if (!is_numeric(intval($balance_amount))) {
$error .= "Параметр не является числом<br>";
}
}
if (empty($balance_currency)) {
$error .= "Не указана валюта<br>";
} else {
if (strlen($balance_currency) > 4) {
$error .= "Параметр слишком длинный<br>";
}
}
if (empty($order_currency)) {
$error .= "Не указана валюта<br>";
} else {
if (strlen($order_currency) > 4) {
$error .= "Параметр слишком длинный<br>";
}
}
if (empty($exchange_rate)) {
$error .= "Не указана сумма<br>";
} else {
if (!is_numeric($exchange_rate)) {
$error .= "Параметр не является числом<br>";
}
}
//если нет ошибок
if (!$error) {
if (is_numeric($pay_for)) {
//Если pay_for - число
$sum = floatval($order_amount);
$rezult = data_get_created_operation($pay_for);
if (mysql_num_rows($rezult) == 1) {
//создаем строку хэша с присланных данных
$md5fb = strtoupper(md5($_REQUEST['type'] . ";" . $pay_for . ";" . $onpay_id . ";" . $order_amount . ";" . $order_currency . ";" . get_constant('private_code')));
//сверяем строчки хеша (присланную и созданную нами)
if ($md5fb != $md5) {
$rezult = answerpay($_REQUEST['type'], 8, $pay_for, $order_amount, $order_currency, 'Md5 signature is wrong. Expected ' . $md5fb, $onpay_id);
} else {
$time = time();
$rezult_balance = get_constant('use_balance_table') ? data_update_user_balance($pay_for, $sum) : true;
$rezult_operation = data_set_operation_processed($pay_for);
//если оба запроса прошли успешно выдаем ответ об удаче, если нет, то о том что операция не произошла
if ($rezult_operation && $rezult_balance) {
$rezult = answerpay($_REQUEST['type'], 0, $pay_for, $order_amount, $order_currency, 'OK', $onpay_id);
} else {
$rezult = answerpay($_REQUEST['type'], 9, $pay_for, $order_amount, $order_currency, 'Error in mechant database queries: operation or balance tables error', $onpay_id);
}
}
} else {
$rezult = answerpay($_REQUEST['type'], 10, $pay_for, $order_amount, $order_currency, 'Cannot find any pay rows acording to this parameters: wrong payment', $onpay_id);
}
} else {
//Если pay_for - не правильный формат
$rezult = answerpay($_REQUEST['type'], 11, $pay_for, $order_amount, $order_currency, 'Error in parameters data', $onpay_id);
}
} else {
//Если есть ошибки
//.........这里部分代码省略.........
示例14: connectToDB
$query = null;
$db_conn = connectToDB();
if ($type == 'Q') {
if ($flag == "true") {
$query = sprintf("UPDATE Question SET answered = 1 WHERE qid = %d", $id);
} else {
$query = sprintf("UPDATE Question SET answered = 0 WHERE qid = %d", $id);
}
if (!mysql_query($query, $db_conn)) {
die("Query error: " . mysql_error());
}
} elseif ($type == 'F') {
if ($flag == "true") {
$query = sprintf("UPDATE Feedback SET isread = 1 WHERE fid = %d", $id);
} else {
$query = sprintf("UPDATE Feedback SET isread = 0 WHERE fid = %d", $id);
}
if (!mysql_query($query, $db_conn)) {
die("Query error: " . mysql_error());
}
}
}
if (isset($_POST['type']) && isset($_POST['id']) && isset($_POST['flag'])) {
$type = $_POST['type'];
// 'Q' for question, 'F' for feedback
$id = $_POST['id'];
// ID for the question or feedback
$flag = $_POST['flag'];
// "true" if we want to set the entry to answered/read, "false" for unanswered/not read
answer($type, $id, $flag);
}
示例15: header
<?php
header('Content-Type: application/json; charset=utf-8');
// Ajax以外からのアクセスを遮断
$request = isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) : '';
if ($request !== 'xmlhttprequest') {
echo json_encode(array("success" => false));
exit;
}
// Ajaxからのアクセスがあれば以下を実行
$json = file_get_contents('php://input');
$data = json_decode($json, true);
if (isset($data["message"]) && $data["message"] !== "") {
$answer = answer(htmlspecialchars($data["message"]));
$result = array("success" => true, "answer" => $answer);
} else {
$result = array("success" => false);
}
$json = json_encode($result);
echo $json;
exit;
/**
* 回答集(CSV)から、質問に対する回答を見つけて返却する。
* @param $question String 質問
* @return $answer String 回答
*/
function answer($question)
{
//返却するデータを初期化。
$answer = "";
if ($fp = @fopen("./data.csv", "r")) {