PHP ctype Functions | ctype Functions In PHP In Hindi

Other Blogs

Blogs ❯❯ PHP

Image could not load

PHP Ctype Functions

PHP में filtering / validation के लिए कई तरह के functions provide किये है like filter_var() , stripslashes() .

इसके अलावा PHP में Ctype Functions भी हैं जिनका use करके need के according characters / String को validate / filter कर सकते हैं

PHP ctype functions in hindi

Ctype extension एक तरह Functions का एक suit है , जिसमे कई useful functions है जो specially किसी string / character को validate करने के लिए use किये जाते है।

यह ध्यान दिया जाना चाहिए कि ctype functions को हमेशा regular expressions से अधिक prefer किया जाता है, यहां तक कि कुछ string functions "str_*" और "is_*" के equivalent भी । इसका कारण है कि ctype , native C library को use करता है। जिसकी वजह से process काफी fast होती है।

ctype function Installation

Windows version के PHP में तो इस extension के लिए already built-in support होते है , तो Windows के लिए आपको install करने की जरूरत नहीं है। हाँ Linux / Mac OS के लिए आपको अलग से install करना पड़ सकता है।

ctype functios

  • ctype_alnum

  • ctype_alpha

  • ctype_cntrl

  • ctype_digit

  • ctype_graph

  • ctype_lower

  • ctype_print

  • ctype_punct

  • ctype_space

  • ctype_upperctype_xdigit

PHP ctype_alnum()

यह function दी गयी value में alphanumeric character को check करता है।

$strings = array("AbCd1zyZ9", "123456", "abcdef#@g"); foreach ($strings as $value) { if (ctype_alnum($value)) { echo "$value consists alphanumeric character(s)"; } else { echo "$value does not consist alphanumeric character(s)"; } }

Output

AbCd1zyZ9 consists alphanumeric character(s)
123456 consists alphanumeric character(s)
abcdef#@g does not consist alphanumeric character(s)

PHP ctype_alpha()

यह function दी गयी value में alphabetic character को check करता है।

$strings = array("bdesdcda", "asdad456", "1232"); foreach ($strings as $value) { if (ctype_alpha($value)) { echo "$value consists alphabetic character(s)"; } else { echo "$value does consist not consist alphabetic character(s)"; } }

Output

bdesdcda consists alphabetic character(s)
asdad456 does not consist alphabetic character(s)
1232 does not consist consist alphabetic character(s) 

PHP ctype_digit()

यह function दी गयी value में numeric character को check करता है।

$arr = array("324$32", "asdad456", "1232"); foreach ($arr as $value) { if (ctype_digit($value)) { echo "$value consists numeric character(s)"; } else { echo "$value does not consist numeric character(s)"; } }

Output

324$32 does not consist numeric alphabetic character(s)
asdad456 does not consist numeric alphabetic character(s)
1232 consists numeric character(s) 

PHP ctype_lower()

यह function दी गयी value में check करता है कि सभी characters lowercase में है।

$arr = array("Rahul", "ravi"); foreach ($arr as $value) { if (ctype_lower($value)) { echo "$value consists all lowercase character(s)"; } else { echo "$value does not consist all lowercase character(s)"; } }

Output

Rahul does not consist all lowercase lowercase character(s)
ravi consists all lowercase character(s) 

PHP ctype_upper()

यह function दी गयी value में check करता है कि सभी characters uppercase में है।

$arr = array("Rahul", "RAVI"); foreach ($arr as $value) { if (ctype_upper($value)) { echo "$value consists all lowercase character(s)"; } else { echo "$value does not consist all lowercase lowercase character(s)"; } }

Output

Rahul does not consist all lowercase lowercase character(s)
RAVI consists all lowercase character(s)
Recent Blogs

Loading ...

Hey ! I'm Rahul founder of learnhindituts.com. Working in IT industry more than 4.5 years. I love to talk about programming as well as writing technical tutorials and blogs that can help to others .... keep learning :)

Get connected with me - LinkedIn Twitter Instagram Facebook

Your Thought ?

Please wait . . .

    0 Comment(s) found !