• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP test_input函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中test_input函数的典型用法代码示例。如果您正苦于以下问题:PHP test_input函数的具体用法?PHP test_input怎么用?PHP test_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test_input函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_spouse

function get_spouse($spouse1, $spouse2, $spouse3)
{
    $spouse1 = test_input($spouse1);
    $spouse2 = test_input($spouse2);
    $spouse3 = test_input($spouse3);
    $num = rand(1, 3);
    switch ($num) {
        case 1:
            return $spouse1;
        case 2:
            return $spouse2;
        case 3:
            return $spouse3;
        default:
            return "Mystery spouse";
    }
}
开发者ID:jlamullins,项目名称:FortuneTeller,代码行数:17,代码来源:results.php


示例2: add_question

 public function add_question()
 {
     $arr['question'] = test_input($_POST['judge_des']);
     $arr['point'] = test_input($_POST['point']);
     $arr['answer'] = $_POST['answer'];
     $arr['easycount'] = intval($_POST['easycount']);
     $arr['isprivate'] = intval($_POST['isprivate']);
     $arr['creator'] = $_SESSION['user_id'];
     $arr['addtime'] = date('Y-m-d H:i:s');
     if (M('ex_judge')->add($arr)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:AzureRay,项目名称:stuexam,代码行数:15,代码来源:AdminjudgeModel.class.php


示例3: register_seller

function register_seller()
{
    global $host, $user, $pass, $dbname;
    $db = new mysqli($host, $user, $pass, $dbname);
    $email = test_input($_POST["semail"]);
    $password = test_input($_POST["spassword"]);
    $confirm_pass = test_input($_POST["sconfirm-password"]);
    $fname = test_input($_POST["sfname"]);
    $lname = test_input($_POST["slname"]);
    $query = "SELECT * FROM SELLER WHERE SELLER.email = '" . $email . "'";
    $result = $db->query($query);
    //echo $query;
    if ($result->num_rows > 0) {
        echo '{"created": false}';
    } else {
        $count_query = "SELECT COUNT(*) FROM SELLER";
        $result2 = $db->query($count_query);
        if ($result2->num_rows > 0) {
            $row = $result2->fetch_assoc();
            $sid = $row["COUNT(*)"];
        } else {
            $sid = 0;
        }
        $insert = "INSERT INTO SELLER (sid, email, password, fname, lname) VALUES (" . $sid . ", '" . $email . "', '" . $password . "', '" . $fname . "', '" . $lname . "');";
        $db->query($insert);
        $token = 256;
        echo '{"created": true, "sid": ' . $sid . ', "fname": "' . $fname . '", "token": ' . $token . '}';
    }
}
开发者ID:rahulreddy-nannuri,项目名称:WebProgrammingProject,代码行数:29,代码来源:register.php


示例4: formFunctions

 /**
  * Test savingForm
  * Test so a proper form is saved, with correct data.
  * Also test if it is possible to enter incorrect data that might ruin something.
  * @author Fredrik Andersson
  * @small
  * @test
  */
 public function formFunctions()
 {
     // Create new user class
     $a = new PP();
     // Check if the object was created
     $this->assertNotNull($a);
     // Adding some variables into the form class PP
     $a->student1 = "StudentName";
     $this->assertEquals("StudentName", $a->student1);
     //Test of the function test_num($data)
     $this->assertEquals(1, test_num(1));
     $this->assertEquals("-", test_num("-"));
     $this->assertEquals("-", test_num(10));
     //Test of the function test_input($data)
     $this->assertEquals("123", test_input("  123  "));
     //trim() removes spaces before the first char and after the last one.
     $this->assertEquals("123'hihi\ttab", test_input("123\\'hi\\hi\ttab"));
     //stripslashes() removes all slashes exept proper slashes like \t and \n etc.
     $this->assertEquals("&amp; &quot; &lt; &gt;", test_input("& \" < >"));
     //htmlspecialchars() changes some special characters to code that html can handle.
     //Test of the function is_empty($data)
     $this->assertEquals(false, is_empty(array('apple', 'banana ', ' cranberry ')));
     $this->assertEquals(false, is_empty(array('', '', '')));
     $temp[10] = "something";
     $this->assertEquals(false, is_empty($temp));
     //Test of the function input_length()
     $string128 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
     $string129 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
     $this->assertEquals($string128, input_length($string129));
     //Test of the function length_one()
     $this->assertEquals("1", length_one("12345"));
 }
开发者ID:RosanderOliver,项目名称:DV1512_Projekt_HT2015,代码行数:40,代码来源:FormTest.php


示例5: addFillInfo

 public function addFillInfo()
 {
     $reqResult = new Result();
     $arr = FillConvert::convertFillFromPost();
     $arr['addtime'] = date('Y-m-d H:i:s');
     $arr['creator'] = $_SESSION['user_id'];
     $fillId = FillBaseModel::instance()->insertData($arr);
     if ($fillId) {
         for ($i = 1; $i <= $arr['answernum']; $i++) {
             $answer = test_input($_POST["answer{$i}"]);
             $arr2['fill_id'] = $fillId;
             $arr2['answer_id'] = $i;
             $arr2['answer'] = $answer;
             M('fill_answer')->add($arr2);
         }
         $pointIds = I('post.point', array());
         KeyPointService::instance()->saveExamPoint($pointIds, $fillId, FillBaseModel::FILL_PROBLEM_TYPE);
         $reqResult->setMessage("填空题添加成功!");
         $reqResult->setData("fill");
     } else {
         $reqResult->setStatus(false);
         $reqResult->setMessage("填空题添加失败!");
     }
     return $reqResult;
 }
开发者ID:sdibt,项目名称:stuexam,代码行数:25,代码来源:FillService.class.php


示例6: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkstu_id'] = test_input($_POST['pkstu_id']);
    $GLOBALS['fkstu_lug_id'] = test_input($_POST['fkstu_lug_id']);
    $GLOBALS['stu_nombre'] = test_input($_POST['stu_nombre']);
    $GLOBALS['stu_fecha_creacion'] = test_input($_POST['stu_fecha_creacion']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:7,代码来源:update-studs.php


示例7: setMessage

function setMessage($data)
{
    if (empty($data)) {
        echo "E-mail couldn't be send without a message";
    } else {
        return test_input($data);
    }
}
开发者ID:Cheshire89,项目名称:Aleksandr-Antonov,代码行数:8,代码来源:send.php


示例8: test_num_meals

function test_num_meals($data)
{
    $data = test_input($data);
    if (!is_numeric($data)) {
        return FALSE;
    }
    return $data;
}
开发者ID:nfallen,项目名称:hudsonhack2015,代码行数:8,代码来源:validation.php


示例9: nomChercheur

function nomChercheur($bdd)
{
    $id = test_input($_SESSION['id']);
    $requete = $bdd->query("SELECT * FROM chercheur WHERE ID = {$id}");
    $data = $requete->fetch();
    $resultat = $data['PrenomChercheur'] . " " . $data['NomChercheur'];
    $requete->closeCursor();
    return $resultat;
}
开发者ID:pgns,项目名称:projet-journal-activite,代码行数:9,代码来源:chercheurAcceuil.modele.php


示例10: convertJudgeFromPost

 public static function convertJudgeFromPost()
 {
     $arr = array();
     $arr['question'] = test_input($_POST['judge_des']);
     $arr['answer'] = $_POST['answer'];
     $arr['easycount'] = intval($_POST['easycount']);
     $arr['isprivate'] = intval($_POST['isprivate']);
     return $arr;
 }
开发者ID:sdibt,项目名称:stuexam,代码行数:9,代码来源:JudgeConvert.class.php


示例11: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkusu_id'] = test_input($_POST['pkusu_id']);
    $GLOBALS['fkusu_rol_id'] = test_input($_POST['fkusu_rol_id']);
    $GLOBALS['usu_nombre'] = test_input($_POST['usu_nombre']);
    $GLOBALS['usu_correo'] = test_input($_POST['usu_correo']);
    $GLOBALS['usu_clave'] = test_input($_POST['usu_clave']);
    $GLOBALS['usu_imagen'] = test_input($_POST['usu_imagen']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:9,代码来源:update-usuarios.php


示例12: convertFillFromPost

 public static function convertFillFromPost()
 {
     $arr = array();
     $arr['question'] = test_input($_POST['fill_des']);
     $arr['easycount'] = intval($_POST['easycount']);
     $arr['answernum'] = intval($_POST['numanswer']);
     $arr['kind'] = intval($_POST['kind']);
     $arr['isprivate'] = intval($_POST['isprivate']);
     return $arr;
 }
开发者ID:sdibt,项目名称:stuexam,代码行数:10,代码来源:FillConvert.class.php


示例13: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkins_id'] = test_input($_POST['pkins_id']);
    $GLOBALS['fkins_car_id'] = test_input($_POST['fkins_car_id']);
    $GLOBALS['fkins_cor_id'] = test_input($_POST['fkins_cor_id']);
    $GLOBALS['ins_valor'] = test_input($_POST['ins_valor']);
    $GLOBALS['ins_gualdrapa'] = test_input($_POST['ins_gualdrapa']);
    $GLOBALS['ins_puesto_partida'] = test_input($_POST['ins_puesto_partida']);
    $GLOBALS['ins_favorito'] = test_input($_POST['ins_favorito']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:10,代码来源:update-inscripciones.php


示例14: updateBaseCodeDef

/**
 * 修改菜单
 **/
function updateBaseCodeDef($baseCodeDefId)
{
    mysql_query("set character_set_connection=utf8");
    $fatherBaseCodeDef = isset($_POST['fatherBaseCodeDef']) ? test_input($_POST['fatherBaseCodeDef']) : "";
    // 父字典code
    $codeValue = isset($_POST['codeValue']) ? test_input($_POST['codeValue']) : "";
    // 字典编码
    $displayValue = isset($_POST['displayValue']) ? test_input($_POST['displayValue']) : "";
    // 字典名称
    mysql_query("update base_code_def set father_base_code ='" . $fatherBaseCodeDef . "', code_value='" . $codeValue . "', display_value='" . $displayValue . "' where base_code_id = " . $baseCodeDefId);
}
开发者ID:yemx910501,项目名称:oes,代码行数:14,代码来源:baseCodeDefAction.php


示例15: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkfac_id'] = test_input($_POST['pkfac_id']);
    // $GLOBALS['pkapu_id'] = test_input($_POST['pkapu_id']);
    // $GLOBALS['fkapu_cor_id'] = test_input($_POST['fkapu_cor_id']);
    // $GLOBALS['fkapu_jug_id'] = test_input($_POST['fkapu_jug_id']);
    // $GLOBALS['fkapu_fac_id'] = test_input($_POST['fkapu_fac_id']);
    // $GLOBALS['fkapu_taq_id'] = test_input($_POST['fkapu_taq_id']);
    // $GLOBALS['apu_monto'] = test_input($_POST['apu_monto']);
    // $GLOBALS['apu_lugar_llegada'] = test_input($_POST['apu_lugar_llegada']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:11,代码来源:update-apuestas.php


示例16: getAverageSalary

 public function getAverageSalary()
 {
     // I am using javascript to validate on the client side, but I am validating on the server side too just in case
     if (empty($_GET["name"])) {
         echo "Search string is required";
         return false;
     } else {
         $name = test_input(cleanGet($_GET));
         //echo $name;
         //exit;
         //$name = test_input($_GET["name"]);
         if (preg_match("/^[a-zA-Z ]*\$/", $name)) {
             echo "The search string is O.K. Look here for the results <br>";
             //exit;
         } else {
             echo "Model1.php says Only letters and white space allowed";
             exit;
         }
     }
     // again, I could have used curl to get the JSON data, but just keeping it simple
     $this->response = file_get_contents('https://data.cityofboston.gov/resource/4swk-wcg8.json');
     $this->response = json_decode($this->response);
     // now, this just loops through the returned object
     foreach ($this->response as $num => &$values) {
         // gets the object properties
         $thevals = get_object_vars($values);
         // assign property values to variables
         $searchstring = $name;
         $mystring1 = $thevals['title'];
         $mystring2 = $thevals['title'];
         $pos1 = stripos($mystring2, $searchstring);
         // Note our use of ===.  Simply == would not work as expected
         // because the positional issues of the 0th (first) character per api documentation.
         if ($pos1 !== false) {
             echo "Found '{$searchstring}' in '{$mystring2}' ==> \$" . $thevals['total_earnings'] . "<br>";
             $totalrows++;
             $sum += $thevals['total_earnings'];
         }
     }
     //calculate the average salary
     if ($totalrows > 0) {
         $average = $sum / $totalrows;
         // report back earnings information as required
         echo "<br>The Grand Total Salary for the " . $searchstring . " positions-> is : " . money_format('%i', $sum) . "<br>";
         echo "The total rows is : " . $totalrows . "<br>";
         echo "The Average salary for the " . $searchstring . " position based on Total Earnings is Grand Total Salary: " . money_format('%i', $sum) . " divided by total number of records " . $totalrows . " = " . money_format('%i', $average) . "<br>";
         return 1;
     } else {
         // no data found, the program will return to the start page, but inform the user. The message may be visible on a slower system.
         echo "Sorry no data found for: " . $searchstring . "<br>";
         return 0;
     }
 }
开发者ID:ga98442w,项目名称:explore_hicommission,代码行数:53,代码来源:model1.php


示例17: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkent_id'] = test_input($_POST['pkent_id']);
    $GLOBALS['fkent_lug_id'] = test_input($_POST['fkent_lug_id']);
    $GLOBALS['ent_ci'] = test_input($_POST['ent_ci']);
    $GLOBALS['ent_primer_nombre'] = test_input($_POST['ent_primer_nombre']);
    $GLOBALS['ent_segundo_nombre'] = test_input($_POST['ent_segundo_nombre']);
    $GLOBALS['ent_primer_apellido'] = test_input($_POST['ent_primer_apellido']);
    $GLOBALS['ent_segundo_apellido'] = test_input($_POST['ent_segundo_apellido']);
    $GLOBALS['ent_fecha_nacimiento'] = test_input($_POST['ent_fecha_nacimiento']);
    $GLOBALS['tel_codigo'] = test_input($_POST['tel_codigo']);
    $GLOBALS['tel_numero'] = test_input($_POST['tel_numero']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:13,代码来源:update-entrenadores.php


示例18: test_string_name

function test_string_name($name_field)
{
    if (empty($_POST["name"])) {
        $data_correct = 0;
        $nameErr = "Name is required";
    } else {
        $name = test_input($_POST["name"]);
        if (!preg_match("/^[a-zA-Z0-9_\\- ]*\$/", $name)) {
            $nameErr = "Only letters and white space allowed";
            $data_correct = 0;
        }
    }
}
开发者ID:hilalevavi,项目名称:industrialProject,代码行数:13,代码来源:index.php


示例19: check

 public function check($source, $items = array())
 {
     foreach ($items as $item => $rules) {
         foreach ($rules as $rule => $rule_value) {
             $value = test_input($source[$item]);
             if ($rule === 'required' && empty($value)) {
                 $this->addError(" Your {$this->getFieldName($rules)} is required.");
             } else {
                 if (!empty($value)) {
                     switch ($rule) {
                         case 'min':
                             if (strlen($value) < $rule_value) {
                                 $this->addError("{$this->getFieldName($rules)} must be a minimum of {$rule_value} characters.");
                             }
                             break;
                         case 'max':
                             if (strlen($value) > $rule_value) {
                                 $this->addError("{$this->getFieldName($rules)} must be no more than {$rule_value} characters.");
                             }
                             break;
                         case 'matches':
                             if ($value !== $source[$rule_value]) {
                                 $this->addError("{$this->getFieldName($rules)} must match your {$rule_value}");
                             }
                             break;
                         case 'unique':
                             $check = $this->_db->get($rule_value, array($item, '=', $value));
                             if ($check->count()) {
                                 $this->addError("{$this->getFieldName($rules)} already exists.");
                             }
                             break;
                         case 'contains':
                             if ($rule_value == 'alnum()' && !ctype_alnum(str_replace([" ", "'"], "", $value))) {
                                 $this->addError("Your {$this->getFieldName($rules)} should only contain letters and spaces.");
                             } else {
                                 if ($rule_value == 'alnum(m:letters)') {
                                     if (!ctype_alnum($value) || ctype_digit($value)) {
                                         $this->addError("Your {$this->getFieldName($rules)} can have alphanumerics but not all numeric.");
                                     }
                                 }
                             }
                     }
                 }
             }
         }
     }
     if (empty($this->_errors)) {
         $this->_passed = true;
     }
     return $this;
 }
开发者ID:kamilik26,项目名称:login-registration-OOP,代码行数:51,代码来源:Validate.php


示例20: setValuesWhenSubmitIsClicked

function setValuesWhenSubmitIsClicked()
{
    $GLOBALS['pkeje_id'] = test_input($_POST['pkeje_id']);
    $GLOBALS['fkeje_har_id'] = test_input($_POST['fkeje_har_id']);
    $GLOBALS['fkeje_pel_id'] = test_input($_POST['fkeje_pel_id']);
    $GLOBALS['fkeje_raz_id'] = test_input($_POST['fkeje_raz_id']);
    $GLOBALS['fkeje_mad_id'] = test_input($_POST['fkeje_mad_id']);
    $GLOBALS['fkeje_pad_id'] = test_input($_POST['fkeje_pad_id']);
    $GLOBALS['eje_fecha_nacimiento'] = test_input($_POST['eje_fecha_nacimiento']);
    $GLOBALS['eje_nombre'] = test_input($_POST['eje_nombre']);
    $GLOBALS['eje_precio'] = test_input($_POST['eje_precio']);
    $GLOBALS['eje_sexo'] = test_input($_POST['eje_sexo']);
    $GLOBALS['eje_tatuaje'] = test_input($_POST['eje_tatuaje']);
}
开发者ID:atahualpasf,项目名称:hipodromo,代码行数:14,代码来源:update-ejemplares.php



注:本文中的test_input函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP test_int函数代码示例发布时间:2022-05-23
下一篇:
PHP test_float函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap