Home  >  Article  >  Backend Development  >  PHP - Convert string to lowercase using mb_strtolower() function

PHP - Convert string to lowercase using mb_strtolower() function

WBOY
WBOYforward
2023-09-14 15:09:03923browse

PHP - 使用mb_strtolower()函数将字符串转换为小写字母

In PHP we can change a given string to lowercase using the function mb_strtolower(). It returns a string with all alphabetic characters converted to lowercase characters.

Syntax

string mb_strtolower(str $string, str $encoding)

Parameters

mb_strtolower()Accepts two parameters: $string and $encoding.

  • $string− Lowercase string, returns a string with all alphabetic characters converted to lowercase characters.

  • $encoding− This parameter is the character encoding. If absent or empty, the internal character encoding value will be used.

  • Return value

    StringAll alphabetic characters are converted to lowercase.

    Example

    Live Demonstration

    <?php
       // Upper and lower case characters are used to
       // convert in lower case using mb_strtoloower function
       $string = "Hello World!, Welcome to ONLINE tutorials";
    
       // It gives the output in lower case
       $string = mb_strtolower($string);
       echo $string;
    ?>

    Output

    It converts all characters in the given string to lowercase.

    hello world! welcome to online tutorials

    The above is the detailed content of PHP - Convert string to lowercase using mb_strtolower() function. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
    Previous article:PHP SSL context optionsNext article:PHP SSL context options