Blogger Information
Blog 57
fans 0
comment 0
visits 47011
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串的大小与转换
藍錄的博客
Original
629 people have browsed it

实例

<?php
/**
 * 字符串的大小写转换
 */

// strtolower()
echo strtolower('THIS IS A PHP COURSE'), '<br>';

// strtoupper()
echo strtoupper('this is a php course'), '<br>';

// ucfirst()
echo ucfirst('this is a php course'), '<br>';

// ucwords()
echo ucwords('this is a php course'), '<br>';

// 应用1: 将文件统一转为小写,实现跨平台(Linux是区分大小写)
echo '<pre>';
$files = ['Model.php','Action.php', 'CreatUser.php'];
foreach ($files as $file) {
    $res[] = strtolower($file);
}
$files = $res;
echo var_export($files, true), '<br>';

// 应用2.将要进行判断的字符串转为统一的格式
$opt = 'EDIT';
switch (strtolower($opt))
{
    case 'select':
        print '查询操作'; break;
    case 'edit':
        print '编辑操作'; break;
    case 'delete':
        print '删除操作'; break;
    case 'update':
        print '更新操作'; break;
   default:
        print '非法操作'; break;

}

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post