Php Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Question No  (16 of 137)
First 12 I 13 I 14 I 15 I 16 I 17 I 18 I 19 I 20 Last
 
Question:-
How can we check the value of a given variable is alphanumeric?
 
Answer:-

bool ctype_alnum ( string $text )

<?php var_dump(ctype_alnum(-1));
// UNIX: bool(false)
// Windows: bool(true)

ctype_alnum() example (using the default locale)

<?php
$strings = array('AbCd1zyZ9', 'foo!#$bar');
foreach ($strings as $testcase) {
    if (ctype_alnum($testcase)) {
        echo "The string $testcase consists of all letters or digits.\n";
    } else {
        echo "The string $testcase does not consist of all letters or digits.\n";
    }
}
?>

The above example will output:

The string AbCd1zyZ9 consists of all letters or digits.
The string foo!#$bar does not consist of all letters or digits.

It is possible to use the dedicated function, ctype_alnum to check whether it is an alphanumeric value or not.

It is possible to use the dedicated function, ctype_alnum to check whether it is an alphanumeric value or not.

  
 
 
 
image
Anil  Bist

Skills    Php

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (5)

Ask 
image
shubham
Ask 
Monika
Ask 
Anamika
Ask 
Riya
Ask 
image
Pooja
 
 

Recommended Classes

image Anil Bist
I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore an...
Professional
image shweta Pandey
Passionate about LIFE and Learning. Lets explore together better version of "self", &qu...
Professional
image shweta Pandey
Passionate about LIFE and Learning. Lets explore together better version of "self", &qu...
Professional