当前位置: 首页>>代码示例>>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;未经允许,请勿转载。