oleku/supervarriable

筛选输入

dev-master 2013-08-22 08:06 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:02:45 UTC


README

这是一个简单的包装器,用于PHP中的 POSTGETREQUEST 或任何 Array

示例

在你的PHP文件中,你想使用的地方

use Oleku\Supervarriable\Varriable;
use Oleku\Supervarriable\Filter\Basic;

// Generate Fake post Data
$_POST['hello'] = "Hello word";



```PHP
//Start super Variable
$_POST = new Varriable($_POST);


/**
 * You can Ignore some fields that should not be filtred
 * eg Binary , XML , JSON etc;
 */

$_POST->ignore("image", "binary");

echo $_POST['hello'], PHP_EOL; // array
echo $_POST->hello, PHP_EOL; // object
echo $_POST("hello"), PHP_EOL; // function

echo $_POST->offsetGet("hello"), PHP_EOL; // direct
echo $_POST->hello(), PHP_EOL; // methods

// Lest have more fun and file array based on path
echo $_POST->find("testing.example.filter"), PHP_EOL;

// This ould not be modified because of ignore
echo $_POST['binary'], PHP_EOL;

/*
 * This would return error because modification is disable but it can be enabled
 * $_POST = new Varriable($_POST,null,Varriable::ALLOW_GET |
 * Varriable::ALLOW_SET);
 */
echo $_POST['hello'] = "Modify";

输出

它们都会给出相同的值

Hello word
Hello word
Hello word
Hello word
Hello word
Let's meet 4:30am �t the caf�
Fatal error: Uncaught exception 'ErrorException' with message 'Offset assignment disabled'

更多示例

许可MIT

Copyright (c) 2013 Oleku Konko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.