valitron-masterPHP資料驗證庫
<?php namespace Valitron; /** * Validation Class * * Validates input against certain criteria * * @package Valitron * @author Vance Lucas <vance@vancelucas.com> * @link http://www.vancelucas.com/ */ class Validator { public function __construct($data = array(), $fields = array(), $lang = null, $langDir = null) { // Allows filtering of used input fields against optional second array of field names allowed // This is useful for limiting raw $_POST or $_GET data to only known fields $this->_fields = !empty($fields) ? array_intersect_key($data, array_flip($fields)) : $data; // set lang in the follow order: constructor param, static::$_lang, default to en $lang = $lang ?: static::lang(); // set langDir in the follow order: constructor param, static::$_langDir, default to package lang dir $langDir = $langDir ?: static::langDir(); // Load language file in directory $langFile = rtrim($langDir, '/') . '/' . $lang . '.php'; if (stream_resolve_include_path($langFile) ) { $langMessages = include $langFile; static::$_ruleMessages = array_merge(static::$_ruleMessages, $langMessages); } else { throw new \InvalidArgumentException("Fail to load language file '" . $langFile . "'"); } }
驗證(Verification)是資訊術語,編譯過程的一部分,在該過程中,對程式碼進行檢查,看是否與定義的特定規則集一致,以允許檢驗某些安全要求。
公共語言運行庫可以驗證Microsoft中間語言(MSIL)。
伺服器端驗證就是當表單提交後,在伺服器端透過JAVA,等伺服器端程式碼對客戶輸入進行驗證。
免責聲明
本站所有資源皆由網友貢獻或各大下載網站轉載。請自行檢查軟體的完整性!本站所有資源僅供學習參考。請不要將它們用於商業目的。否則,一切後果都由您負責!如有侵權,請聯絡我們刪除。聯絡方式:admin@php.cn
相關文章

05 Nov 2024
Node.js 套件參考指南 核心依賴 網路框架和伺服器 特快專遞 (^4.18.2) 網路應用程式框架 處理路由、中介軟體和 HTTP 請求/回應 建立 API 的核心基礎與我們

03 Dec 2024
JSON(JavaScript 物件表示法)因其簡單性和可讀性而成為 API 和 Web 應用程式的首選資料格式。無論您是使用 API 回應還是設定文件,了解如何比較 JSON 數據

23 Oct 2024
在 Go 語言中,資料驗證是常見且必要的,因為語言鼓勵明確錯誤檢查。 雖然 Go 簡單且高效,但有幾個函式庫使資料驗證變得更加容易。 圖書館的優勢


Hot Tools

熱門文章
丟失記錄:Bloom&Rage -Corey和Dylan的鎖組合
19 Feb 2025
手游攻略
Hello Kitty Island冒險:重新啟動機器人任務演練
16 Feb 2025
手游攻略
丟失的記錄:Bloom&Rage-成就/獎杯指南
19 Feb 2025
手游攻略
命運2:異端 - 淡淡的活動指南
05 Feb 2025
手游攻略
如何僅在資料不存在時才將資料插入MySQL?
25 Jan 2025
mysql教程