當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Variable::setVariable方法代碼示例

本文整理匯總了PHP中Variable::setVariable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::setVariable方法的具體用法?PHP Variable::setVariable怎麽用?PHP Variable::setVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Variable的用法示例。


在下文中一共展示了Variable::setVariable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setData

             $answer = null;
         }
         $this->data[strtoupper($variablename)] = $answer;
         return $this->data[strtoupper($variablename)];
     }
     return null;
 }
 function setData($variablename, $answer, $clean = 1)
 {
     /* variable in memory */
     if (isset($this->variables[strtoupper($variablename)])) {
         $variable = $this->variables[strtoupper($variablename)];
     } else {
         $variable = new Variable();
         if (!$variable->setVariable($variablename)) {
             $variable = null;
         }
     }
     /* we have variable */
     if ($variable != null) {
         $variable->setDirty($clean);
         /* check for EMPTY */
         if (strtoupper($answer) == VARIABLE_VALUE_EMPTY || is_array($answer) && sizeof($answer) == 0 || !is_array($answer) && trim($answer) == "") {
             $answer = null;
         }
         if ($variable->setAnswer($this->primkey, $answer)) {
             /* update in-memory */
             $this->variables[strtoupper($variablename)] = $variable;
             $this->data[strtoupper($variablename)] = $answer;
             //echo 'set ' . $variablename .  ' to ' . $answer;
             /* update state memory if array update 
              * (this does not happen in variable.php via $engine->setAnswer()
              * in order to avoid an infinite loop)
              */
             global $engine;
             $var = $engine->getVariableDescriptive($variablename);
             if ($var->isArray() && contains($variablename, "[")) {
                 //echo 'set ' . $variablename .  ' to ' . $answer;
                 $arr = $this->getData(getBasicName($variablename));
                 $index = str_replace("]", "", substr($variablename, strrpos($variablename, "[") + 1));
                 // update array
                 $arr[$index] = $answer;
                 // flatten array
                 $arr = flatten($arr);
                 // flatten array
                 $this->data[strtoupper(getBasicName($variablename))] = $arr;
                 //print_r($arr);
             } else {
                 if (($var->getAnswerType() == ANSWER_TYPE_SETOFENUMERATED || $var->getAnswerType() == ANSWER_TYPE_MULTIDROPDOWN) && !contains($variablename, "_")) {
                     $options = $var->getOptions();
                     $values = explode(SEPARATOR_SETOFENUMERATED, $answer);
                     foreach ($options as $o) {
                         $code = $o["code"];
                         if (isset($this->data[strtoupper($variablename . "_" . $code . "_")])) {
                             if (!inArray($code, $values)) {
                                 $this->data[strtoupper($variablename . "_" . $code . "_")] = null;
                             }
                         } else {
                             if (inArray($code, $values)) {
                                 $this->data[strtoupper($variablename . "_" . $code . "_")] = $code;
                             }
                         }
開發者ID:nubissurveying,項目名稱:nubis,代碼行數:62,代碼來源:state.php


注:本文中的Variable::setVariable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。