Kohana 之Inflector

没什么用,这个类

但也有一两个常用点的,记录下

 

转换首字母大写并合并空格

<?php
$str = Inflector::camelize('mother cat');  //"motherCat"
 
将下滑线,中线转为空格
<?php
$str = Inflector::humanize('kittens-are-cats'); // "kittens are cats" 

将空格专为下划线
<?php
$str = Inflector::underscore('five cats'); // "five_cats";


检查拼写(没什么用)
Inflector::uncountable('fish'); // TRUEInflector::uncountable('cat');  // FALSE
config/inflector.php定义
 

删除复数

echo Inflector::singular('cats'); // "cat"

变为复数

echo Inflector::plural('fish'); // "fish", uncountable

posted @ 2010-08-19 16:42  liushan  阅读(141)  评论(0)    收藏  举报