一组有用的is条件。

dev-master 2015-10-26 22:52 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:20:30 UTC


README

Is for PHP 是一个小型库,提供了一些方便的方法来快速检查或验证变量内容。

安装它

通过composer安装库

composer install flyandi/is

如何使用它

非常简单。库公开了静态类 Is,其中包含所有评估方法,例如。

$AnArray = ['red', 'blue', green];

$AnColor = '#00FF00';

if(Is::_array($AnArray)) echo "Yes, it's an array!";

if(Is::hexcolor($AnColor)) echo "This is a valid color code.";

方法

Is库目前实现了以下方法

此外,库还提供了一些基本的验证表达式过滤器

其他实现

这个库最初是用JavaScript为Meteor编写的(http://github.com/flyandi/meteor-is),并实现了相同的方法和过滤器。