《PHP學習:PHP將字符串首字母大小寫轉換的實例》要點:
本文介紹了PHP學習:PHP將字符串首字母大小寫轉換的實例,希望對您有用。如果有疑問,可以聯系我們。
PHP應用每個單詞的首字母轉換為大寫:ucwords()
PHP應用
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
PHP應用第一個單詞首字母變大寫:ucfirst()
PHP應用
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
PHP應用第一個單詞首字母變小寫:lcfirst()
PHP應用
<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
PHP應用所有 字母變大寫:strtoupper()
PHP應用所有 字母變小寫:strtolower()
PHP應用以上這篇PHP將字符串首字母大小寫轉換的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持維易PHP.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/1928.html