PHP Online Compiler
Example: PHP program to check whether input character is vowel or consonant
C
C++
C#
Java
Python
PHP
main.php
STDIN
Run
<?php // PHP program to check whether input character is vowel or consonant using if-else $x = "O"; $l = 0; $u = 0; // $l denotes for lowercase vowels // $u denotes for uppercase vowels // ctype_alpha() function checks // whether character is alphabetic or non-alphabetic if ($x && ctype_alpha($x)) { // this will return 1 if input character matched with these small characters $l = $x == 'a' || $x == 'e' || $x == 'i' || $x == 'o' || $x == 'u'; // this will return 1 if input character matched with these capital characters $u = $x == 'A' || $x == 'E' || $x == 'I' || $x == 'O' || $x == 'U'; if ($l || $u) echo "'" . $x . "' is a vowel character.\n"; else echo "'" . $x . "' is a consonant character.\n"; } else { echo "Sorry, You entered Non-Alphabetic character!\n"; } ?>
Output
Clear
ADVERTISEMENTS