Home » PHP » PHP Ctype functions

PHP ctype_lower() function with example

PHP ctype_lower() function: Here, we are going to learn about the ctype_lower() function with example in PHP.
Submitted by IncludeHelp, on February 04, 2019

PHP ctype_lower() function

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.

It returns true, if all characters of the given strings are in lowercase, else it returns false.

Syntax:

    ctype_lower(string) : bool

Example:

    Input: "hello"
    Output: true
    Input: "hello world"
    Output: false
    Input: "Hello"
    Output: false

PHP code:

<?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

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.





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.