PHP Chinese-English character conversion size word code

Source: Internet
Author: User
Tags lowercase

Converts the first letter of each word to uppercase: Ucwords ()
Capitalize the first letter of a word: Ucfirst ()
First letter to lowercase: lcfirst ()
Capitalize all letters: Strtoupper ()

Example

The code is as follows Copy Code

<?php
Echo strtoupper ("Hello world!");
?>

Output:

HELLO world!

Capitalize the first letter of a word: Ucfirst ()

The code is as follows Copy Code

<?php
$foo = ' where are doing?! ';
$foo = Ucfirst ($foo); Where are doing?!

$bar = ' where are doing?! ';
$bar = Ucfirst ($bar); Where are doing?!
$bar = Ucfirst (Strtolower ($bar)); Where are doing?!
?>

All letters to lowercase: strtolower ()

The code is as follows Copy Code

<?php
$str = "Mary Had A Little Lamb and She loved It so";
$str = Strtolower ($STR);
Echo $str; Prints Mary had a little lamb and she loved it so
?>


Converts the first letter of each word to uppercase: Ucwords ()

The code is as follows Copy Code

<?php
$foo = ' where are doing?! ';
$foo = Ucwords ($foo); Where are doing?!

$bar = ' where are doing?! ';
$bar = Ucwords ($bar); Where are doing?!
$bar = Ucwords (Strtolower ($bar)); Where are doing?!
?>



First letter to lowercase: lcfirst ()

  code is as follows copy code

<?php
$foo = ' HelloWorld ';
$foo = Lcfirst ($foo);            //Where are doing

$bar = ' where are doing?! ';
$bar = Lcfirst ($bar);            //Where are doing ?!
$bar = Lcfirst (Strtoupper ($bar));//Where are doing?!
?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.