PHP ctype_lower() Function (With Examples)

In this tutorial, we will learn about the PHP ctype_lower() function with its usage, syntax, parameters, return value, and examples. By IncludeHelp Last updated : December 31, 2023

PHP ctype_lower() function

The ctype_lower() function is a character type (CType) function in PHP, it is used to check whether a given string contains lowercase characters or not.

Syntax

The syntax of the ctype_lower() function:

ctype_lower(string) : bool

Parameters

The parameters of the ctype_lower() function:

  • string: An input string.

Return Value

The return type of this method is bool, it returns true, if all characters of the given strings are in lowercase, else it returns false.

Sample Input/Output

Input: "hello"
Output: true

Input: "hello world"
Output: false

Input: "Hello"
Output: false

PHP ctype_lower() Function Example

<?php
    $str = "hello";
    if(ctype_lower($str))
        echo ("$str contains all lowercase characters.\n");
    else
        echo ("$str does not contain all lowercase characters.\n");

    $str = "hello world"; //space is there
    if(ctype_lower($str))
        echo ("$str contains all lowercase characters.\n");
    else
        echo ("$str does not contain all lowercase characters.\n");

    $str = "hello123"; //digits are there 
    if(ctype_lower($str))
        echo ("$str contains all lowercase characters.\n");
    else
        echo ("$str does not contain all lowercase characters.\n");

    $str = "Hello"; //an uppercase character is there
    if(ctype_lower($str))
        echo ("$str contains all lowercase characters.\n");
    else
        echo ("$str does not contain all lowercase characters.\n");	
?>

Output

The output of the above example is:

hello contains all lowercase characters.
hello world does not contain all lowercase characters.
hello123 does not contain all lowercase characters.
Hello does not contain all lowercase characters.

To understand the above example, you should have the basic knowledge of the following PHP topics:

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.